private Enumeration FindOrCreateFilterFunctionsEnumeration()
        {
            foreach (var enumeration in Project.Enumerations)
            {
                if (enumeration.GetAttributeValue("isFilterFunctionsEnumeration", NamespaceUri, false))
                {
                    return(enumeration);
                }
            }

            Enumeration e = Project.Enumerations.FirstOrDefault(_ => string.Equals(_.Name, "FilterFunction", StringComparison.OrdinalIgnoreCase) || string.Equals(_.Name, "FilterFunctions", StringComparison.OrdinalIgnoreCase));

            if (e != null)
            {
                return(e);
            }

            e           = new Enumeration();
            e.Name      = typeof(FilterFunctions).Name;
            e.Namespace = Project.DefaultNamespace;
            e.IsFlags   = Project.GetAttributeValue("createMultiValuedEnumeration", NamespaceUri, true);
            e.SetAttributeValue(PreferredPrefix, "isFilterFunctionsEnumeration", NamespaceUri, true);
            Project.Enumerations.Add(e);

            foreach (FilterFunctions value in ConvertUtilities.EnumEnumerateValues <FilterFunctions>())
            {
                EnumerationValue enumerationValue = new EnumerationValue();
                enumerationValue.Name = value.ToString();
                enumerationValue.SetAttributeValue(PreferredPrefix, "filterFunction", NamespaceUri, value);
                e.Values.Add(enumerationValue);
            }

            return(e);
        }
Exemple #2
0
        private Enumeration FindOrCreateFilterFunctionsEnumeration()
        {
            foreach (Enumeration enumeration in Project.Enumerations)
            {
                if (enumeration.GetAttributeValue("isFilterFunctionsEnumeration", NamespaceUri, false))
                {
                    return(enumeration);
                }
            }

            Enumeration e = Project.Enumerations.FirstOrDefault(_ => string.Equals(_.Name, "FilterFunction", StringComparison.OrdinalIgnoreCase) || string.Equals(_.Name, "FilterFunctions", StringComparison.OrdinalIgnoreCase));

            if (e != null)
            {
                return(e);
            }

            e           = new Enumeration();
            e.Name      = typeof(FilterFunctions).Name;
            e.Namespace = Project.DefaultNamespace;
            e.IsFlags   = Project.GetAttributeValue("createMultiValuedEnumeration", NamespaceUri, true);
            e.SetAttributeValue(PreferredPrefix, "isFilterFunctionsEnumeration", NamespaceUri, true);
            Project.Enumerations.Add(e);

            foreach (FilterFunctions value in ConvertUtilities.EnumEnumerateValues <FilterFunctions>())
            {
                EnumerationValue enumerationValue = new EnumerationValue();
                enumerationValue.Name = value.ToString();
                enumerationValue.SetAttributeValue(PreferredPrefix, "filterFunction", NamespaceUri, value);

                List <string> enumNames = ConvertUtilities.SplitEnumNames(value).ToList();
                if (enumNames.Count() > 1)
                {
                    if (!e.IsFlags)
                    {
                        continue;
                    }

                    enumerationValue.Value = ConvertUtilities.Concatenate(enumNames, " | ");
                }
                else
                {
                    enumerationValue.Value = ((int)value).ToString(CultureInfo.InvariantCulture);
                }

                enumerationValue.Value = ((int)value).ToString(CultureInfo.InvariantCulture);
                e.Values.Add(enumerationValue);
            }

            return(e);
        }
        static ExtendedSearchAspect()
        {
            var    values = ConvertUtilities.EnumEnumerateValues <FilterFunctions>();
            string filterFunctionEditorTypeName = "enum:";

            foreach (var value in values)
            {
                filterFunctionEditorTypeName += string.Format("{0}={1},", value, (int)value);
            }

            filterFunctionEditorTypeName = filterFunctionEditorTypeName.TrimEnd(';');
            string multiValueFilterFunctionEditorTypeName = "mv" + filterFunctionEditorTypeName;

            Descriptor = new XmlDocument();
            Descriptor.LoadXml(
                @"<cf:project xmlns:cf='http://www.softfluent.com/codefluent/2005/1' defaultNamespace='ExtendedSearchAspect'>
                    <cf:pattern name='Extended Search Aspect' namespaceUri='" + NamespaceUri + @"' preferredPrefix='" + PreferredPrefix + @"' step='Start'>
                        <cf:message class='_doc'>
                        SoftFluent Samples - Extended Search Aspect
                        This aspect is used to customize Search methods. It modifies methods (BOM and SQL) to support dynamic filter functions (Equals, StartsWith, EndsWith, Contains, FreeText, ...)
                        </cf:message>

                        <cf:descriptor name='defaultEnabled' 
                                targets='Project, Entity' 
                                defaultValue='false' 
                                displayName='Default is Enabled' 
                                typeName='boolean' 
                                category='Extended Search Aspect' />
                        
                        <cf:descriptor name='enabled' 
                                targets='Method, Parameter' 
                                defaultValue='false' 
                                displayName='Is Enabled' 
                                typeName='boolean' 
                                category='Extended Search Aspect' />

                        <cf:descriptor name='defaultParameterNameFormat' 
                                targets='Project, Entity, Method' 
                                defaultValue='" + DefaultParameterNameFormat + @"' 
                                displayName='Default Parameter Name Format' 
                                typeName='string' 
                                category='Extended Search Aspect' />
                        
                        <cf:descriptor name='parameterNameFormat' 
                                targets='Parameter' 
                                defaultValue='" + DefaultParameterNameFormat + @"' 
                                displayName='Parameter Name Format' 
                                typeName='string' 
                                category='Extended Search Aspect' />

                        <cf:descriptor name='defaultFilterFunctions' 
                                targets='Project, Entity, Method' 
                                defaultValue='" + DefaultFilterFunctions.ToString() + @"' 
                                displayName='Default Filter Functions' 
                                editorTypeName='" + multiValueFilterFunctionEditorTypeName + @"' 
                                category='Extended Search Aspect' />

                        <cf:descriptor name='filterFunctions' 
                                targets='Parameter' 
                                defaultValue='" + DefaultFilterFunctions.ToString() + @"' 
                                displayName='Filter Functions' 
                                editorTypeName='" + multiValueFilterFunctionEditorTypeName + @"' 
                                category='Extended Search Aspect' />

                        <cf:descriptor name='isFilterFunctionsEnumeration' 
                                targets='Enumeration' 
                                defaultValue='false' 
                                displayName='Is Filter Functions Enumeration' 
                                typeName='boolean' 
                                category='Extended Search Aspect' />

                        <cf:descriptor name='filterFunction' 
                                targets='EnumerationValue' 
                                defaultValue='None' 
                                displayName='Filter Function' 
                                editorTypeName='" + filterFunctionEditorTypeName + @"' 
                                category='Extended Search Aspect' />

                        <cf:descriptor name='createMultiValuedEnumeration' 
                                targets='Project' 
                                defaultValue='true' 
                                displayName='Create multi-valued enumeration' 
                                typeName='boolean' 
                                category='Extended Search Aspect' />
                  </cf:pattern>
                </cf:project>");
        }