Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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();
        }