Esempio n. 1
0
        protected override List <string> OnValidate(string lambdaExpression, PageConfigurableProfile profile)
        {
            List <string> list = new List <string>();

            string[] array = lambdaExpression.Split(new string[]
            {
                "=>"
            }, StringSplitOptions.None);
            string[] array2 = array[0].Split(new char[]
            {
                ',',
                ' '
            }, StringSplitOptions.RemoveEmptyEntries);
            string[] array3 = array2;
            for (int i = 0; i < array3.Length; i++)
            {
                string columnName = array3[i];
                if (profile.ColumnProfiles.All((ColumnProfile columnProfile) => !columnName.Equals(columnProfile.Name)))
                {
                    list.Add(string.Format("{0} in input columns is not a valid column name in lambda expression", columnName));
                }
            }
            string text = array[1];

            foreach (string arg in array2)
            {
                string value = string.Format("@0[{0}]", arg);
                if (!text.Contains(value))
                {
                    list.Add(string.Format("Column {0} is not used in lambda expression {1}", arg, lambdaExpression));
                }
            }
            return(list);
        }
 public override bool HasPermission()
 {
     if (!string.IsNullOrEmpty(this.Schema) && null != this.Assembly)
     {
         PageConfigurableProfile pageConfigurableProfile = AutomatedDataHandlerBase.BuildProfile(this.Assembly, this.Schema) as PageConfigurableProfile;
         return(pageConfigurableProfile.HasPermission());
     }
     return(base.HasPermission());
 }
Esempio n. 3
0
        public override List <string> Validate(object target, PageConfigurableProfile profile)
        {
            List <string> list = new List <string>();

            if (this.ReportError)
            {
                list.Add("MockDDIAttribute error: " + profile.Name);
            }
            return(list);
        }
        public List <string> Validate(object target, PageConfigurableProfile profile)
        {
            string text = target as string;

            if (string.IsNullOrEmpty(text))
            {
                return(new List <string>());
            }
            return(this.OnValidate(text, profile));
        }
Esempio n. 5
0
        public override List <string> Validate(object target, PageConfigurableProfile profile)
        {
            List <string> list = new List <string>();

            if (WinformsHelper.IsEmptyValue(target))
            {
                list.Add("cannot be null or empty");
            }
            return(list);
        }
        public override List <string> Validate(object target, PageConfigurableProfile profile)
        {
            IEnumerable target2 = null;

            if (target != null)
            {
                IDictionary dictionary = target as IDictionary;
                if (dictionary == null)
                {
                    throw new ArgumentException("DDIDictionaryDecorateAttribute can only be applied to type which implemented the IDictionary interface");
                }
                target2 = (this.UseKeys ? dictionary.Keys : dictionary.Values);
            }
            return(base.Validate(target2, profile));
        }
Esempio n. 7
0
        public override List <string> Validate(object target, PageConfigurableProfile profile)
        {
            if (target != null && !(target is string))
            {
                throw new ArgumentException("DDIDataObjectNameExistAttribute can only apply to String property");
            }
            string        dataObjectName = target as string;
            List <string> list           = new List <string>();

            if (!string.IsNullOrEmpty(dataObjectName) && profile.DataObjectProfiles.All((DataObjectProfile dataObject) => !dataObject.Name.Equals(dataObjectName)))
            {
                list.Add(string.Format("{0} is not a valid data object name", target));
            }
            return(list);
        }
        protected override List <string> OnValidate(string lambdaExpression, PageConfigurableProfile profile)
        {
            List <string> list = new List <string>();

            try
            {
                ColumnExpression expression = ExpressionCalculator.BuildColumnExpression(lambdaExpression);
                DataTable        dataTable  = new DataTable();
                DataRow          dataRow    = dataTable.NewRow();
                ExpressionCalculator.CompileLambdaExpression(expression, typeof(object), dataRow, null);
            }
            catch (Exception ex)
            {
                list.Add(string.Format("Fail to compile lambda expression {0} with error {1}", lambdaExpression, ex.ToString()));
            }
            return(list);
        }
        public override List <string> Validate(object target, PageConfigurableProfile profile)
        {
            if (target != null && !(target is string))
            {
                throw new ArgumentException("DDIValidPropertyPageNameAttribute can only be applied to String");
            }
            if (DDIValidPropertyPageNameAttribute.propertyPageNames.Count == 0)
            {
                this.UpdatePropertyPageNames();
            }
            List <string> list = new List <string>();

            if (target != null && !DDIValidPropertyPageNameAttribute.propertyPageNames.Contains(target as string))
            {
                list.Add(target + " is not a valid property page name");
            }
            return(list);
        }
Esempio n. 10
0
        public override List <string> Validate(object target, PageConfigurableProfile profile)
        {
            if (target != null && !(target is string))
            {
                throw new ArgumentException("DDIValidLambdaExpressionAttribute can only apply to String property");
            }
            List <string> list = new List <string>();

            foreach (LambdaExpressionRule lambdaExpressionRule in DDIValidLambdaExpressionAttribute.rules)
            {
                list.AddRange(lambdaExpressionRule.Validate(target, profile));
                if (list.Count > 0)
                {
                    break;
                }
            }
            return(list);
        }
Esempio n. 11
0
        protected override List <string> OnValidate(string lambdaExpression, PageConfigurableProfile profile)
        {
            List <string> list = new List <string>();

            string[] array = lambdaExpression.Split(new string[]
            {
                "=>"
            }, StringSplitOptions.None);
            if (array.Length == 1)
            {
                list.Add(string.Format("{0} separator is required for lambda expression {1}", "=>", lambdaExpression));
            }
            else if (array.Length > 2)
            {
                list.Add(string.Format("Multiply {0} separators are found in lambda expression {1}", "=>", lambdaExpression));
            }
            return(list);
        }
        public override List <string> Validate(object target, PageConfigurableProfile profile)
        {
            List <string> list = new List <string>();

            if (target != null)
            {
                IEnumerable enumerable = target as IEnumerable;
                if (enumerable == null)
                {
                    throw new ArgumentException("DDINoDuplicationAttribute can only be applied to Collection object");
                }
                if (enumerable.OfType <object>().Count <object>() > 0)
                {
                    PropertyInfo propertyInfo = null;
                    if (!string.IsNullOrEmpty(this.PropertyName))
                    {
                        object obj = enumerable.OfType <object>().First <object>();
                        propertyInfo = obj.GetType().GetProperty(this.PropertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
                        if (propertyInfo == null)
                        {
                            throw new ArgumentException(string.Format("{0} is not a valid property in class {1}", this.PropertyName, obj.GetType().FullName));
                        }
                        enumerable.GetEnumerator().Reset();
                    }
                    Dictionary <object, int> dictionary = new Dictionary <object, int>();
                    foreach (object obj2 in enumerable)
                    {
                        object obj3 = (propertyInfo != null) ? propertyInfo.GetValue(obj2, null) : obj2;
                        if (obj3 != null)
                        {
                            dictionary[obj3] = (dictionary.ContainsKey(obj3) ? (dictionary[obj3] + 1) : 1);
                        }
                    }
                    foreach (object obj4 in dictionary.Keys)
                    {
                        if (dictionary[obj4] > 1)
                        {
                            list.Add(string.Format("Duplicated element {0} found in collection", obj4));
                        }
                    }
                }
            }
            return(list);
        }
Esempio n. 13
0
        public override List <string> Validate(object target, PageConfigurableProfile profile)
        {
            if (target != null && !(target is string))
            {
                throw new ArgumentException("DDIValidCommandTextAttribute can only be applied to String property");
            }
            if (DDIValidCommandTextAttribute.cmdlets.Count == 0)
            {
                this.UpdateCmdlets();
            }
            List <string> list = new List <string>();
            string        text = target as string;

            if (!string.IsNullOrEmpty(text) && !DDIValidCommandTextAttribute.cmdlets.Contains(text.ToUpper()))
            {
                list.Add(string.Format("{0} is not a valid cmdlet name", target));
            }
            return(list);
        }
        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);
        }
        public override List <string> Validate(object target, PageConfigurableProfile profile)
        {
            List <string> list          = new List <string>();
            ColumnProfile columnProfile = target as ColumnProfile;

            if (columnProfile != null && !columnProfile.PersistWholeObject)
            {
                string mappingProperty = columnProfile.MappingProperty;
                string dataObjectName  = columnProfile.DataObjectName;
                if (!string.IsNullOrEmpty(dataObjectName) && !string.IsNullOrEmpty(mappingProperty))
                {
                    if (profile.DataObjectProfiles.Any((DataObjectProfile dataobject) => dataObjectName.Equals(dataobject.Name)))
                    {
                        Type         type     = profile.DataObjectProfiles.First((DataObjectProfile dataobject) => dataObjectName.Equals(dataobject.Name)).Type;
                        PropertyInfo property = type.GetProperty(mappingProperty, BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
                        if (property == null)
                        {
                            list.Add(string.Format("{0} is not a valid property in data object {1}", mappingProperty, type.FullName));
                        }
                    }
                }
            }
            return(list);
        }
 protected abstract List <string> OnValidate(string lambdaExpression, PageConfigurableProfile profile);
Esempio n. 17
0
 public virtual List <string> Validate(object target, PageConfigurableProfile profile)
 {
     return(new List <string>());
 }