Saving
This commit is contained in:
1 parent
9719a0c0fd
commit
1e66851113
146 files changed
+738
-382
No files matched your search
@@ -0,0 +1,38 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Reflection;
|
||||
|
||||
namespace PrivaPub.ClientModels
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class AtLeastOnePropertyAttribute : ValidationAttribute
|
||||
{
|
||||
private string[] PropertyList { get; set; }
|
||||
|
||||
public AtLeastOnePropertyAttribute(params string[] propertyList)
|
||||
{
|
||||
PropertyList = propertyList;
|
||||
}
|
||||
|
||||
public override object TypeId
|
||||
{
|
||||
get
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsValid(object value)
|
||||
{
|
||||
PropertyInfo propertyInfo;
|
||||
foreach (string propertyName in PropertyList)
|
||||
{
|
||||
propertyInfo = value.GetType().GetProperty(propertyName);
|
||||
|
||||
if (propertyInfo != null && propertyInfo.GetValue(value, null) != null)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user