Exemple #1
0
        public IEnumerable <IConceptInfo> CreateNewConcepts(IEnumerable <IConceptInfo> existingConcepts)
        {
            var itemFilter = new ItemFilterInfo
            {
                Expression = String.Format("item => item.{0} != null && item.{1} != null && item.{0} > item.{1}", PropertyFrom.Name, PropertyTo.Name),
                FilterName = PropertyFrom.Name + "_" + PropertyTo.Name + "_RangeFilter",
                Source     = PropertyFrom.DataStructure
            };
            var invalidData = new InvalidDataInfo
            {
                Source       = PropertyFrom.DataStructure,
                FilterType   = itemFilter.FilterName,
                ErrorMessage = "Value of {0} has to be less than or equal to {1}."
            };
            var messageParameters = new InvalidDataMessageParametersConstantInfo
            {
                InvalidData       = invalidData,
                MessageParameters = CsUtility.QuotedString(PropertyFrom.Name) + ", " + CsUtility.QuotedString(PropertyTo.Name)
            };
            var invalidProperty = new InvalidDataMarkProperty2Info
            {
                InvalidData  = invalidData,
                MarkProperty = PropertyFrom
            };

            return(new IConceptInfo[] { itemFilter, invalidData, messageParameters, invalidProperty });
        }
Exemple #2
0
        public IEnumerable <IConceptInfo> CreateNewConcepts(IEnumerable <IConceptInfo> existingConcepts)
        {
            string filterName = "SystemRequired" + Property.Name;

            var filter = new ItemFilterInfo
            {
                Source     = Property.DataStructure,
                FilterName = filterName,
                Expression = "item => item." + Property.Name + " == null"
            };
            var invalidData = new InvalidDataInfo
            {
                Source       = Property.DataStructure,
                FilterType   = filterName,
                ErrorMessage = "System required property {0} is not set."
            };
            var messageParameters = new InvalidDataMessageParametersConstantInfo
            {
                InvalidData       = invalidData,
                MessageParameters = CsUtility.QuotedString(Property.GetUserDescription())
            };
            var invalidProperty = new InvalidDataMarkProperty2Info
            {
                InvalidData  = invalidData,
                MarkProperty = Property
            };

            return(new IConceptInfo[] { filter, invalidData, messageParameters, invalidProperty });
        }
Exemple #3
0
 public IEnumerable<IConceptInfo> CreateNewConcepts(IEnumerable<IConceptInfo> existingConcepts)
 {
     var itemFilter = new ItemFilterInfo
     {
         Expression = String.Format("item => item.{0} != null && item.{1} != null && item.{0} > item.{1}", PropertyFrom.Name, PropertyTo.Name),
         FilterName = PropertyFrom.Name + "_" + PropertyTo.Name + "_RangeFilter",
         Source = PropertyFrom.DataStructure
     };
     var invalidData = new InvalidDataInfo
     {
         Source = PropertyFrom.DataStructure,
         FilterType = itemFilter.FilterName,
         ErrorMessage = "Value of {0} has to be less than or equal to {1}."
     };
     var messageParameters = new InvalidDataMessageParametersConstantInfo
     {
         InvalidData = invalidData,
         MessageParameters = CsUtility.QuotedString(PropertyFrom.Name) + ", " + CsUtility.QuotedString(PropertyTo.Name)
     };
     var invalidProperty = new InvalidDataMarkProperty2Info
     {
         InvalidData = invalidData,
         MarkProperty = PropertyFrom
     };
     return new IConceptInfo[] { itemFilter, invalidData, messageParameters, invalidProperty };
 }
        public IEnumerable<IConceptInfo> CreateNewConcepts(IEnumerable<IConceptInfo> existingConcepts)
        {
            string filterName = "SystemRequired" + Property.Name;

            var filter = new ItemFilterInfo
            {
                Source = Property.DataStructure,
                FilterName = filterName,
                Expression = "item => item." + Property.Name + " == null"
            };

            var invalidData = new InvalidDataInfo
            {
                Source = Property.DataStructure,
                FilterType = filterName,
                ErrorMessage = "System required property {0} is not set."
            };
            var messageParameters = new InvalidDataMessageParametersConstantInfo
            {
                InvalidData = invalidData,
                MessageParameters = CsUtility.QuotedString(Property.GetUserDescription())
            };
            var invalidProperty = new InvalidDataMarkProperty2Info
            {
                InvalidData = invalidData,
                MarkProperty = Property
            };

            return new IConceptInfo[] { filter, invalidData, messageParameters, invalidProperty };
        }
Exemple #5
0
        public IEnumerable <IConceptInfo> CreateNewConcepts(IEnumerable <IConceptInfo> existingConcepts)
        {
            var itemFilter = new ItemFilterInfo
            {
                Expression = String.Format("item => !String.IsNullOrEmpty(item.{0}) && item.{0}.Length > {1}", Property.Name, Length),
                FilterName = Property.Name + "_MaxLengthFilter",
                Source     = Property.DataStructure
            };
            var invalidData = new InvalidDataInfo
            {
                Source       = Property.DataStructure,
                FilterType   = itemFilter.FilterName,
                ErrorMessage = "Maximum allowed length of {0} is {1} characters."
            };
            var messageParameters = new InvalidDataMessageParametersConstantInfo
            {
                InvalidData       = invalidData,
                MessageParameters = CsUtility.QuotedString(Property.Name) + ", " + Length
            };
            var invalidProperty = new InvalidDataMarkProperty2Info
            {
                InvalidData  = invalidData,
                MarkProperty = Property
            };

            return(new IConceptInfo[] { itemFilter, invalidData, messageParameters, invalidProperty });
        }
Exemple #6
0
        public IEnumerable <IConceptInfo> CreateNewConcepts()
        {
            var filterParameter = new ParameterInfo
            {
                Module = Property.DataStructure.Module,
                Name   = Property.Name + "_RegExMatchFilter",
            };

            string filterExpression = string.Format(@"(source, parameter) =>
                {{
                    var items = source.Where(item => !string.IsNullOrEmpty(item.{0})).Select(item => new {{ item.ID, item.{0} }}).ToList();
                    var regex = new System.Text.RegularExpressions.Regex({1});
                    var invalidItemIds = items.Where(item => !regex.IsMatch(item.{0})).Select(item => item.ID).ToList();
                    return Filter(source, invalidItemIds);
                }}",
                                                    Property.Name,
                                                    CsUtility.QuotedString("^" + RegularExpression + "$"));

            var itemFilter = new QueryFilterExpressionInfo
            {
                Expression = filterExpression,
                Parameter  = filterParameter.Module.Name + "." + filterParameter.Name,
                Source     = Property.DataStructure
            };
            var invalidData = new InvalidDataInfo
            {
                Source       = Property.DataStructure,
                FilterType   = itemFilter.Parameter,
                ErrorMessage = ErrorMessage
            };
            var invalidProperty = new InvalidDataMarkProperty2Info
            {
                InvalidData  = invalidData,
                MarkProperty = Property
            };

            return(new IConceptInfo[] { filterParameter, itemFilter, invalidData, invalidProperty });
        }
Exemple #7
0
        public IEnumerable <IConceptInfo> CreateNewConcepts(IEnumerable <IConceptInfo> existingConcepts)
        {
            string limitSnippet = LimitSnippetByType
                                  .Where(snippet => snippet.Key.IsAssignableFrom(Property.GetType()))
                                  .Select(snippet => snippet.Value.Invoke(Value))
                                  .Single();

            var filterParameter = new ParameterInfo
            {
                Module = Property.DataStructure.Module,
                Name   = Property.Name + "_MinValueFilter"
            };
            var filter = new ComposableFilterByInfo
            {
                Expression = String.Format(@"(items, repository, parameter) => {{ {1}; return items.Where(item => item.{0} != null && item.{0} < limit); }}", Property.Name, limitSnippet),
                Parameter  = filterParameter.Module.Name + "." + filterParameter.Name,
                Source     = Property.DataStructure
            };
            var invalidData = new InvalidDataInfo
            {
                Source       = Property.DataStructure,
                FilterType   = filter.Parameter,
                ErrorMessage = "Minimum value of {0} is {1}."
            };
            var messageParameters = new InvalidDataMessageParametersConstantInfo
            {
                InvalidData       = invalidData,
                MessageParameters = CsUtility.QuotedString(Property.Name) + ", " + CsUtility.QuotedString(Value)
            };
            var invalidProperty = new InvalidDataMarkProperty2Info
            {
                InvalidData  = invalidData,
                MarkProperty = Property
            };

            return(new IConceptInfo[] { filterParameter, filter, invalidData, messageParameters, invalidProperty });
        }
        public IEnumerable <IConceptInfo> CreateNewConcepts(IEnumerable <IConceptInfo> existingConcepts)
        {
            string filterName = "RequiredAllowSave" + Property.Name;

            string emptyStringOrCondition = (Property is ShortStringPropertyInfo || Property is LongStringPropertyInfo)
                ? "|| item." + Property.Name + " == \"\" "
                : "";

            var filter = new ItemFilterInfo
            {
                Source     = Property.DataStructure,
                FilterName = filterName,
                Expression = "item => item." + Property.Name + " == null " + emptyStringOrCondition + OrCondition.Evaluate(this)
            };
            var invalidData = new InvalidDataInfo
            {
                Source       = Property.DataStructure,
                FilterType   = filterName,
                ErrorMessage = "The required property {0} is not set."
            };
            var messageParameters = new InvalidDataMessageParametersConstantInfo
            {
                InvalidData       = invalidData,
                MessageParameters = CsUtility.QuotedString(Property.Name)
            };
            var invalidProperty = new InvalidDataMarkProperty2Info
            {
                InvalidData  = invalidData,
                MarkProperty = Property
            };
            var allowSave = new InvalidDataAllowSaveInfo
            {
                InvalidData = invalidData
            };

            return(new IConceptInfo[] { filter, invalidData, messageParameters, invalidProperty, allowSave });
        }
Exemple #9
0
 public IEnumerable<IConceptInfo> CreateNewConcepts(IEnumerable<IConceptInfo> existingConcepts)
 {
     var itemFilter = new ItemFilterInfo
     {
         Expression = String.Format("item => !String.IsNullOrEmpty(item.{0}) && item.{0}.Length > {1}", Property.Name, Length),
         FilterName = Property.Name + "_MaxLengthFilter",
         Source = Property.DataStructure
     };
     var invalidData = new InvalidDataInfo
     {
         Source = Property.DataStructure,
         FilterType = itemFilter.FilterName,
         ErrorMessage = "Maximum allowed length of {0} is {1} characters."
     };
     var messageParameters = new InvalidDataMessageParametersConstantInfo
     {
         InvalidData = invalidData,
         MessageParameters = CsUtility.QuotedString(Property.Name) + ", " + Length
     };
     var invalidProperty = new InvalidDataMarkProperty2Info
     {
         InvalidData = invalidData,
         MarkProperty = Property
     };
     return new IConceptInfo[] { itemFilter, invalidData, messageParameters, invalidProperty };
 }
Exemple #10
0
        public IEnumerable<IConceptInfo> CreateNewConcepts(IEnumerable<IConceptInfo> existingConcepts)
        {
            string limitSnippet = LimitSnippetByType
                .Where(snippet => snippet.Key.IsAssignableFrom(Property.GetType()))
                .Select(snippet => snippet.Value.Invoke(Value))
                .Single();

            var filterParameter = new ParameterInfo
            {
                Module = Property.DataStructure.Module,
                Name = Property.Name + "_MinValueFilter"
            };
            var filter = new ComposableFilterByInfo
            {
                Expression = String.Format(@"(items, repository, parameter) => {{ {1}; return items.Where(item => item.{0} != null && item.{0} < limit); }}", Property.Name, limitSnippet),
                Parameter = filterParameter.Module.Name + "." + filterParameter.Name,
                Source = Property.DataStructure
            };
            var invalidData = new InvalidDataInfo
            {
                Source = Property.DataStructure,
                FilterType = filter.Parameter,
                ErrorMessage = "Minimum value of {0} is {1}."
            };
            var messageParameters = new InvalidDataMessageParametersConstantInfo
            {
                InvalidData = invalidData,
                MessageParameters = CsUtility.QuotedString(Property.Name) + ", " + CsUtility.QuotedString(Value)
            };
            var invalidProperty = new InvalidDataMarkProperty2Info
            {
                InvalidData = invalidData,
                MarkProperty = Property
            };
            return new IConceptInfo[] { filterParameter, filter, invalidData, messageParameters, invalidProperty };
        }
Exemple #11
0
        public IEnumerable<IConceptInfo> CreateNewConcepts(IEnumerable<IConceptInfo> existingConcepts)
        {
            var filterParameter = new ParameterInfo
            {
                Module = Property.DataStructure.Module,
                Name = Property.Name + "_RegExMatchFilter",
            };

            string filterExpression = string.Format(@"(source, repository, parameter) =>
                {{
                    var items = source.Where(item => !string.IsNullOrEmpty(item.{0})).Select(item => new {{ item.ID, item.{0} }}).ToList();
                    var regex = new System.Text.RegularExpressions.Regex({1});
                    var invalidItemIds = items.Where(item => !regex.IsMatch(item.{0})).Select(item => item.ID).ToList();
                    return Filter(source, invalidItemIds);
                }}",
                Property.Name,
                CsUtility.QuotedString("^" + RegularExpression + "$"));

            var itemFilter = new ComposableFilterByInfo
            {
                Expression = filterExpression,
                Parameter = filterParameter.Module.Name + "." + filterParameter.Name,
                Source = Property.DataStructure
            };
            var invalidData = new InvalidDataInfo
            {
                Source = Property.DataStructure,
                FilterType = itemFilter.Parameter,
                ErrorMessage = ErrorMessage
            };
            var invalidProperty = new InvalidDataMarkProperty2Info
            {
                InvalidData = invalidData,
                MarkProperty = Property
            };
            return new IConceptInfo[] { filterParameter, itemFilter, invalidData, invalidProperty };
        }