IEnumerable <IValidatedElement> IValidatedType.GetValidatedProperties()
        {
            MetadataValidatedElement iteratorVariable0 = new MetadataValidatedElement(this.Ruleset);

            foreach (PropertyInfo iteratorVariable1 in this.TargetType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (ValidationReflectionHelper.IsValidProperty(iteratorVariable1))
                {
                    iteratorVariable0.UpdateFlyweight(iteratorVariable1);
                    yield return(iteratorVariable0);
                }
            }
        }
Exemple #2
0
        public static PropertyInfo GetProperty(Type type, string propertyName, bool throwIfInvalid)
        {
            if (string.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentNullException("propertyName");
            }
            PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public);

            if (!ValidationReflectionHelper.IsValidProperty(property))
            {
                if (throwIfInvalid)
                {
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.ExceptionInvalidProperty, propertyName, type.FullName));
                }
                return(null);
            }
            return(property);
        }
Exemple #3
0
        IEnumerable <IValidatedElement> IValidatedType.GetValidatedProperties()
        {
            MetadataValidatedElement flyweight = new MetadataValidatedElement(base.Ruleset);

            try
            {
                PropertyInfo[] properties = base.TargetType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
                foreach (PropertyInfo propertyInfo in properties)
                {
                    if (ValidationReflectionHelper.IsValidProperty(propertyInfo))
                    {
                        flyweight.UpdateFlyweight(propertyInfo);
                        yield return((IValidatedElement)flyweight);
                    }
                }
            }
            finally
            {
            }
        }
Exemple #4
0
        IEnumerable <IValidatedElement> IValidatedType.GetValidatedProperties()
        {
            MetadataValidatedElement metadataValidatedElement = new MetadataValidatedElement(base.Ruleset);

            try
            {
                PropertyInfo[] properties = base.TargetType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
                for (int i = 0; i < properties.Length; i++)
                {
                    PropertyInfo propertyInfo = properties[i];
                    if (ValidationReflectionHelper.IsValidProperty(propertyInfo))
                    {
                        metadataValidatedElement.UpdateFlyweight(propertyInfo);
                        yield return(metadataValidatedElement);
                    }
                }
            }
            finally
            {
            }
            yield break;
        }