public static bool Validate(ISetting setting) { var settingType = setting.GetType(); var settingParameters = settingType.GetProperties() .Where(p => AttributeRetrieval.GetAttributes <ValidateAttribute>(p).Any()) .Select(p => new { Info = p, Value = p.GetValue(setting) }) .ToList(); return(settingParameters.All(p => Validate(settingType, p.Info, p.Value))); }
public static bool Validate(IFilter filter) { var filterType = filter.GetType(); var filterParameters = filterType.GetProperties() .Where(p => AttributeRetrieval.GetAttributes <ValidateAttribute>(p).Any()) .Select(p => new { Info = p, Value = p.GetValue(filter) }) .ToList(); return(filterParameters.All(p => Validate(filterType, p.Info, p.Value))); }
/// <summary> /// returns a boolean indicating if <cref name="objectType"/> is applicable to <cref name="restrictedType"/> /// </summary> public static bool ContainsStream(Type objectType, Type streamType) { var matchingAttributes = AttributeRetrieval.GetAttributes <ContainsStreamAttribute>(objectType); if (matchingAttributes.Count == 0) { return(false); } return(matchingAttributes.Any(attribute => (attribute.Type == streamType || attribute.Type.IsAssignableFrom(streamType)))); }
public static bool Validate(Type objectType, PropertyInfo propertyInfo, object value) { var validateAttributes = AttributeRetrieval.GetAttributes <ValidateAttribute>(propertyInfo); return(validateAttributes == null || !validateAttributes.Any() || validateAttributes.All(va => ValidateSingle(propertyInfo, va, value))); }