コード例 #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 });
        }
コード例 #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 });
        }
コード例 #3
0
ファイル: RangeInfo.cs プロジェクト: davorpr1/Rhetos
 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 };
 }
コード例 #4
0
ファイル: SystemRequiredInfo.cs プロジェクト: davorpr1/Rhetos
        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 };
        }
コード例 #5
0
ファイル: MaxLengthInfo.cs プロジェクト: TinOroz/Rhetos
        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 });
        }
コード例 #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 });
        }
コード例 #7
0
ファイル: MinValueInfo.cs プロジェクト: TinOroz/Rhetos
        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 });
        }
コード例 #8
0
        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 });
        }
コード例 #9
0
ファイル: MaxLengthInfo.cs プロジェクト: davorpr1/Rhetos
 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 };
 }
コード例 #10
0
ファイル: MinValueInfo.cs プロジェクト: davorpr1/Rhetos
        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 };
        }
コード例 #11
0
ファイル: RegExMatchInfo.cs プロジェクト: davorpr1/Rhetos
        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 };
        }