コード例 #1
0
        public static void AddLocale(string providerName, IEnumerable <Type> interfaceTypes, CultureInfo cultureInfo)
        {
            XmlDataProviderConfiguration xmlDataProviderConfiguration = new XmlDataProviderConfiguration(providerName);

            foreach (Type type in interfaceTypes)
            {
                if (!DataLocalizationFacade.IsLocalized(type))
                {
                    continue;
                }

                var dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(type);

                object key = xmlDataProviderConfiguration.Section.Interfaces.GetKey(dataTypeDescriptor);

                var oldConfigurationElement = xmlDataProviderConfiguration.Section.Interfaces.Get(key);
                var newConfigurationElement = BuildXmlProviderInterfaceConfigurationElement(dataTypeDescriptor, cultureInfo, null, oldConfigurationElement);

                xmlDataProviderConfiguration.Section.Interfaces.Remove(key);
                xmlDataProviderConfiguration.Section.Interfaces.Add(newConfigurationElement);

                foreach (Dictionary <string, DataScopeConfigurationElement> filesByCulture in newConfigurationElement.DataScopes.Values)
                {
                    XmlDataProviderStoreManipulator.CreateStore(providerName, filesByCulture[cultureInfo.Name]);
                }
            }

            xmlDataProviderConfiguration.Save();
        }
コード例 #2
0
        /// <summary>
        /// Create an invariant store
        /// </summary>
        /// <param name="providerName"></param>
        /// <param name="dataTypeDescriptor"></param>
        public static void AddNew(string providerName, DataTypeDescriptor dataTypeDescriptor)
        {
            var xmlDataProviderConfiguration = new XmlDataProviderConfiguration(providerName);

            string interfaceType = dataTypeDescriptor.TypeManagerTypeName;

            if (interfaceType != null)
            {
                object key = xmlDataProviderConfiguration.Section.Interfaces.GetKey(dataTypeDescriptor);

                if (key != null)
                {
                    Log.LogWarning(LogTitle,
                                   "Configuration file '{0}' already contains an interface type '{1} 'with id '{2}'. "
                                   + "Possibly there are multiple AppDomain-s running.",
                                   xmlDataProviderConfiguration.ConfigurationFilePath, dataTypeDescriptor, dataTypeDescriptor.DataTypeId);
                    return;
                }
            }

            XmlProviderInterfaceConfigurationElement configurationElement = BuildXmlProviderInterfaceConfigurationElement(dataTypeDescriptor);

            XmlDataProviderStoreManipulator.CreateStore(providerName, configurationElement);

            xmlDataProviderConfiguration.Section.Interfaces.Add(configurationElement);

            xmlDataProviderConfiguration.Save();
        }
コード例 #3
0
        public static void Remove(string providerName, DataTypeDescriptor dataTypeDescriptor)
        {
            XmlDataProviderConfiguration xmlDataProviderConfiguration = new XmlDataProviderConfiguration(providerName);

            object key = xmlDataProviderConfiguration.Section.Interfaces.GetKey(dataTypeDescriptor);

            if (key != null)
            {
                XmlProviderInterfaceConfigurationElement element = xmlDataProviderConfiguration.Section.Interfaces.Get(key);

                xmlDataProviderConfiguration.Section.Interfaces.Remove(key);
                xmlDataProviderConfiguration.Save();

                XmlDataProviderStoreManipulator.DropStore(providerName, element);
            }
        }
コード例 #4
0
        public static XmlProviderInterfaceConfigurationElement Change(UpdateDataTypeDescriptor updateDataTypeDescriptor)
        {
            DataTypeChangeDescriptor changeDescriptor = updateDataTypeDescriptor.CreateDataTypeChangeDescriptor();

            var xmlDataProviderConfiguration = new XmlDataProviderConfiguration(updateDataTypeDescriptor.ProviderName);

            object key = xmlDataProviderConfiguration.Section.Interfaces.GetKey(changeDescriptor.OriginalType);

            var oldConfigurationElement = xmlDataProviderConfiguration.Section.Interfaces.Get(key);
            var newConfigurationElement = BuildXmlProviderInterfaceConfigurationElement(changeDescriptor.AlteredType, oldConfigurationElement);

            XmlDataProviderStoreManipulator.AlterStore(updateDataTypeDescriptor, oldConfigurationElement, newConfigurationElement);

            xmlDataProviderConfiguration.Section.Interfaces.Remove(key);
            xmlDataProviderConfiguration.Section.Interfaces.Add(newConfigurationElement);

            xmlDataProviderConfiguration.Save();

            return(newConfigurationElement);
        }
コード例 #5
0
        public static void RemoveLocale(string providerName, IEnumerable <Type> interfaceTypes, CultureInfo cultureInfo)
        {
            XmlDataProviderConfiguration xmlDataProviderConfiguration = new XmlDataProviderConfiguration(providerName);

            foreach (Type type in interfaceTypes)
            {
                if (DataLocalizationFacade.IsLocalizable(type))
                {
                    DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(type);

                    object key = xmlDataProviderConfiguration.Section.Interfaces.GetKey(dataTypeDescriptor);

                    bool configurationChanged = false;

                    var oldConfigurationElement = xmlDataProviderConfiguration.Section.Interfaces.Get(key);
                    foreach (Dictionary <string, DataScopeConfigurationElement> scopesByLanguage in oldConfigurationElement.DataScopes.Values)
                    {
                        if (scopesByLanguage.ContainsKey(cultureInfo.Name))
                        {
                            XmlDataProviderStoreManipulator.DropStore(providerName, scopesByLanguage[cultureInfo.Name]);
                            configurationChanged = true;
                        }
                    }

                    if (configurationChanged)
                    {
                        var newConfigurationElement = BuildXmlProviderInterfaceConfigurationElement(dataTypeDescriptor, null, cultureInfo, oldConfigurationElement);

                        xmlDataProviderConfiguration.Section.Interfaces.Remove(key);
                        xmlDataProviderConfiguration.Section.Interfaces.Add(newConfigurationElement);
                    }
                }
            }

            xmlDataProviderConfiguration.Save();
        }