Exemple #1
0
        protected DDIValidateAttribute GetDDIAttribute()
        {
            DDIValidateAttribute result = null;

            if (this.AttributeType != null)
            {
                try
                {
                    result = (Activator.CreateInstance(this.AttributeType) as DDIValidateAttribute);
                }
                catch (ArgumentException)
                {
                }
                catch (NotSupportedException)
                {
                }
                catch (TargetInvocationException)
                {
                }
                catch (MethodAccessException)
                {
                }
                catch (MemberAccessException)
                {
                }
                catch (TypeLoadException)
                {
                }
            }
            return(result);
        }
        public override List <string> Validate(object target, PageConfigurableProfile profile)
        {
            DDIValidateAttribute ddiattribute = base.GetDDIAttribute();

            if (ddiattribute == null)
            {
                throw new ArgumentException(string.Format("{0} is not a valid DDIAttribute", base.AttributeType));
            }
            List <string> list = new List <string>();

            if (target != null)
            {
                IEnumerable enumerable = target as IEnumerable;
                if (enumerable == null)
                {
                    throw new ArgumentException("DDICollectionDecoratorAttribute can only be applied to collection target");
                }
                foreach (object obj in enumerable)
                {
                    if (this.ExpandInnerCollection && obj is IEnumerable)
                    {
                        using (IEnumerator enumerator2 = (obj as IEnumerable).GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                object target2 = enumerator2.Current;
                                list.AddRange(ddiattribute.Validate(target2, profile));
                            }
                            continue;
                        }
                    }
                    list.AddRange(ddiattribute.Validate(obj, profile));
                }
            }
            return(list);
        }