コード例 #1
0
        //------------------------------------------------------------------------------
        IEnumerable <string> GetSimpleSettingsNamesImpl(IEnumerable <string> fullSettingsNames)
        {
            if (fullSettingsNames == null)
            {
                return(null);
            }

            var settingsNames = new List <string>();
            var serializer    = SettingsHelper.GetSerializerDependFromSettingAttributeType(this.Context, typeof(ATTRIBUTE));

            var delimeter = SettingNameFormatInfo.GetSettingNameDelimeter(serializer as ISettingsSerializerWishes);

            foreach (var fullSettingName in fullSettingsNames)
            {
                string formatVersionPrefix;
                string typeInfo;
                string settingName;

                var parseResult = SettingNameFormatInfo.Parse(fullSettingName,
                                                              delimeter,
                                                              out formatVersionPrefix,
                                                              out typeInfo,
                                                              out settingName,
                                                              SettingNameMode.Dynamic);

                if (parseResult)
                {
                    settingsNames.Add(settingName);
                }
            }

            return(settingsNames);
        }
コード例 #2
0
        //------------------------------------------------------------------------------
        public IEnumerable <string> GetDynamicSettingsNames()
        {
            var delimeter            = SettingNameFormatInfo.GetSettingNameDelimeter(this as ISettingsSerializerWishes);
            var dynamicSettingsNames = m_Store.GetFileNames(SettingNameFormatInfo.DynamicSettingNamePrefix + delimeter + "*");

            return(dynamicSettingsNames);
        }
コード例 #3
0
        //------------------------------------------------------------------------------
        IEnumerable <string> GetDynamicSettingsNamesForType(ISettingsSerializer serializer, Type settingsType, bool respectOrder)
        {
            IEnumerable <string> result = null;

            var dynamicSettingsInfo = (IDynamicSettingsInfo)serializer;

            var delimeter = SettingNameFormatInfo.GetSettingNameDelimeter(serializer as ISettingsSerializerWishes);

            var settingsTypeInfo = SettingNameFormatInfo.GetSettingsTypeInfo(settingsType, serializer as ISettingsSerializerWishes);
            var settingsNames    = dynamicSettingsInfo.GetDynamicSettingsNames();

            var filteredSettingsNames = new List <string>();

            foreach (var rawSettingName in settingsNames)
            {
                string formatVersion;
                string typeInfo;
                string name;

                bool parseResult = SettingNameFormatInfo.Parse(rawSettingName, delimeter,
                                                               out formatVersion, out typeInfo, out name,
                                                               SettingNameMode.Dynamic);

                if (parseResult)
                {
                    if (settingsTypeInfo == typeInfo)
                    {
                        filteredSettingsNames.Add(rawSettingName);
                    }
                }
            }

            result = filteredSettingsNames;

            if (respectOrder)
            {
                var settingsOrder = LoadDynamicSettingsDefaultOrder(serializer, settingsType);
                if (settingsOrder != null)
                {
                    var fullSettingsNamesCustomOrder = new List <string>();
                    foreach (var simpleSettingName in settingsOrder)
                    {
                        var fullSettingName = SettingNameFormatInfo.GetFullSettingName(simpleSettingName,
                                                                                       serializer as ISettingsSerializerWishes,
                                                                                       settingsType,
                                                                                       SettingNameMode.Dynamic);
                        fullSettingsNamesCustomOrder.Add(fullSettingName);
                    }

                    // берём только то, что есть в каждой коллекции
                    result = fullSettingsNamesCustomOrder.Intersect(result);
                }
            }

            return(result);
        }
コード例 #4
0
        //------------------------------------------------------------------------------
        public static string GetSettingsTypeInfo(Type settingsType, ISettingsSerializerWishes wishes)
        {
            var delimeter = SettingNameFormatInfo.GetSettingNameDelimeter(wishes);

            string settingsTypeInfo;

            if (wishes != null)
            {
                var updatedNamespaceName = wishes.RemoveInappropriateSymbols(settingsType.Namespace);
                var updatedClassName     = wishes.RemoveInappropriateSymbols(settingsType.Name);

                settingsTypeInfo = updatedNamespaceName + delimeter + updatedClassName;
            }
            else
            {
                settingsTypeInfo = settingsType.Namespace + delimeter + settingsType.Name;
            }

            return(settingsTypeInfo);
        }