예제 #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();
        }