Example #1
0
        private void BuildSpecialTraceSources()
        {
            SpecialTraceSourcesNode specialSourcesNode = (SpecialTraceSourcesNode)hierarchy.FindNodeByType(loggingSettingsNode, typeof(SpecialTraceSourcesNode));

            if (specialSourcesNode != null)
            {
                ErrorsTraceSourceNode errorSourceNode = (ErrorsTraceSourceNode)hierarchy.FindNodeByType(specialSourcesNode, typeof(ErrorsTraceSourceNode));
                if (errorSourceNode != null)
                {
                    loggingSettings.SpecialTraceSources.ErrorsTraceSource = errorSourceNode.TraceSourceData;
                    BuildTraceListenerReferences(loggingSettings.SpecialTraceSources.ErrorsTraceSource, errorSourceNode);
                }
                AllTraceSourceNode allTraceSourceNodes = (AllTraceSourceNode)hierarchy.FindNodeByType(specialSourcesNode, typeof(AllTraceSourceNode));
                if (allTraceSourceNodes != null)
                {
                    loggingSettings.SpecialTraceSources.AllEventsTraceSource = allTraceSourceNodes.TraceSourceData;
                    BuildTraceListenerReferences(loggingSettings.SpecialTraceSources.AllEventsTraceSource, allTraceSourceNodes);
                }
                NotProcessedTraceSourceNode notProcessedSourceNode = (NotProcessedTraceSourceNode)hierarchy.FindNodeByType(specialSourcesNode, typeof(NotProcessedTraceSourceNode));
                if (notProcessedSourceNode != null)
                {
                    loggingSettings.SpecialTraceSources.NotProcessedTraceSource = notProcessedSourceNode.TraceSourceData;
                    BuildTraceListenerReferences(loggingSettings.SpecialTraceSources.NotProcessedTraceSource, notProcessedSourceNode);
                }
            }
        }
        public void Build()
        {
            ConnectionStringsSectionNode node = hierarchy.FindNodeByType(typeof(ConnectionStringsSectionNode)) as ConnectionStringsSectionNode;

            if (null == node)
            {
                LogError(hierarchy.RootNode, Resources.ExceptionMissingConnectionStrings);
                return;
            }

            for (int index = 0; index < oracleConnectionSettings.OracleConnectionsData.Count; ++index)
            {
                OracleConnectionData         oracleConnection     = oracleConnectionSettings.OracleConnectionsData.Get(index);
                ConnectionStringSettingsNode connectionStringNode = hierarchy.FindNodeByName(node, oracleConnection.Name) as ConnectionStringSettingsNode;
                if (null == connectionStringNode)
                {
                    LogError(node, string.Format(CultureInfo.CurrentUICulture, Resources.ExceptionConnectionStringMissing, oracleConnection.Name));
                    continue;
                }
                OracleConnectionElementNode oracleElementNode = new OracleConnectionElementNode();
                foreach (OraclePackageData packageData in oracleConnection.Packages)
                {
                    oracleElementNode.AddNode(new OraclePackageElementNode(packageData));
                }
                connectionStringNode.AddNode(oracleElementNode);
            }
        }
Example #3
0
        private void RemoveConfigurationSourceElements(IConfigurationUIHierarchy configurationUIHierarchy)
        {
            ConfigurationSourceSectionNode configurationSourcesNode = configurationUIHierarchy.FindNodeByType(typeof(ConfigurationSourceSectionNode)) as ConfigurationSourceSectionNode;

            if (configurationSourcesNode != null)
            {
                configurationSourcesNode.Remove();
            }
        }
        public override void Save(IServiceProvider serviceProvider)
        {
            IErrorLogService         errorService            = ServiceHelper.GetErrorService(serviceProvider);
            IEnvironmentMergeService environmentMergeService = serviceProvider.GetService(typeof(IEnvironmentMergeService)) as IEnvironmentMergeService;

            if (environmentMergeService != null)
            {
                if (environmentMergeService.EnvironmentMergeInProgress)
                {
                    return;
                }
            }

            IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);

            Debug.Assert(hierarchy != null);

            ConfigurationApplicationNode configurationRootNode = hierarchy.FindNodeByType(typeof(ConfigurationApplicationNode)) as ConfigurationApplicationNode;

            Debug.Assert(configurationRootNode != null);

            string configurationFileDirectory = Path.GetDirectoryName(configurationRootNode.ConfigurationFile);

            foreach (EnvironmentNode environmentNode in hierarchy.FindNodesByType(typeof(EnvironmentNode)))
            {
                string environmentDeltaFilePath =
                    Path.Combine(configurationFileDirectory, environmentNode.EnvironmentDeltaFile);

                Dictionary <string, ConfigurationNodeMergeData> mergeDataByPath =
                    environmentNode.EnvironmentMergeData.UnfoldMergeData(hierarchy, false);
                EnvironmentMergeSection environmentMergeSection = new EnvironmentMergeSection();
                environmentMergeSection.EnvironmentName      = environmentNode.Name;
                environmentMergeSection.EnvironmentDeltaFile = environmentNode.EnvironmentConfigurationFile;

                CopyEnvironmentOverrides(environmentMergeSection, mergeDataByPath, hierarchy);
                string protectionProvider = GetProtectionProviderName(environmentNode);

                try
                {
                    FileConfigurationSource fileConfigurationSource =
                        new FileConfigurationSource(environmentDeltaFilePath, false);
                    if (!string.IsNullOrEmpty(protectionProvider))
                    {
                        fileConfigurationSource.Save(EnvironmentMergeSection.EnvironmentMergeData, environmentMergeSection, protectionProvider);
                    }
                    else
                    {
                        fileConfigurationSource.Add(EnvironmentMergeSection.EnvironmentMergeData, environmentMergeSection);
                    }
                }
                catch (ConfigurationErrorsException configurationErrors)
                {
                    errorService.LogErrors(configurationErrors);
                }
            }
        }
        void BuildLogFilters()
        {
            LogFilterCollectionNode logFilterCollectionNode
                = (LogFilterCollectionNode)hierarchy.FindNodeByType(loggingSettingsNode, typeof(LogFilterCollectionNode));

            if (logFilterCollectionNode != null)
            {
                foreach (LogFilterNode filterNode in logFilterCollectionNode.Nodes)
                {
                    loggingSettings.LogFilters.Add(filterNode.LogFilterData);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Adds a <see cref="CachingStoreProviderNode"/> and the Caching Application Block if it is not already part of the application.
        /// </summary>
        /// <param name="node">The node to add the <see cref="CachingStoreProviderNode"/> to.</param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            base.ExecuteCore(node);

            IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(ServiceProvider);

            if (hierarchy.FindNodeByType(typeof(CacheManagerSettingsNode)) == null)
            {
                ConfigurationApplicationNode currentApplicationNode = hierarchy.RootNode;
                if (currentApplicationNode != null)
                {
                    new AddCacheManagerSettingsNodeCommand(ServiceProvider).Execute(currentApplicationNode);

                    CacheManagerNode defaultCacheManager = (CacheManagerNode)hierarchy.FindNodeByType(typeof(CacheManagerNode));
                    if (defaultCacheManager != null && ChildNode != null)
                    {
                        ((CachingStoreProviderNode)ChildNode).CacheManager = defaultCacheManager;
                        hierarchy.SelectedNode = ChildNode;
                    }
                }
            }
        }
Example #7
0
        private EnvironmentNode LoadConfigurationMergeFile(IConfigurationUIHierarchy mainConfigurationHierarchy, string configurationMergeFile, IServiceProvider serviceProvider)
        {
            EnvironmentNodeBuilder nodeBuilder     = new EnvironmentNodeBuilder(serviceProvider);
            EnvironmentNode        environmentNode = nodeBuilder.Build(configurationMergeFile, mainConfigurationHierarchy);

            EnvironmentalOverridesNode environmentNodeContainer = mainConfigurationHierarchy.FindNodeByType(typeof(EnvironmentalOverridesNode)) as EnvironmentalOverridesNode;

            if (environmentNodeContainer == null)
            {
                throw new ApplicationException(Resources.ErrorNoEnvironmentContainer);
            }
            environmentNodeContainer.AddNode(environmentNode);

            return(environmentNode);
        }
Example #8
0
        private void BuildCacheManagers()
        {
            foreach (CacheManagerNode managerNode in hierarchy.FindNodesByType(cacheSettingsNode, typeof(CacheManagerNode)))
            {
                CacheManagerData cacheManagerData      = managerNode.CacheManagerData;
                CacheStorageNode storageNodeForManager = (CacheStorageNode)hierarchy.FindNodeByType(managerNode, typeof(CacheStorageNode));
                cacheManagerData.CacheStorage = (storageNodeForManager == null) ? Resources.NullStorageName : storageNodeForManager.Name;

                if (cacheManagerData.CacheStorage == Resources.NullStorageName && !cacheConfiguration.BackingStores.Contains(Resources.NullStorageName))
                {
                    cacheConfiguration.BackingStores.Add(new CacheStorageData(Resources.NullStorageName, typeof(NullBackingStore)));
                }

                cacheConfiguration.CacheManagers.Add(cacheManagerData);
            }
        }
 private void RemoveConfigurationSourceElements(IConfigurationUIHierarchy configurationUIHierarchy)
 {
     ConfigurationSourceSectionNode configurationSourcesNode
         = configurationUIHierarchy.FindNodeByType(typeof(ConfigurationSourceSectionNode)) as ConfigurationSourceSectionNode;
     if (configurationSourcesNode != null)
     {
         configurationSourcesNode.Remove();
     }
 }
Example #10
0
        private void BuildSecurityCacheProviders()
        {
            SecurityCacheProviderCollectionNode securityCacheCollectionNode = (SecurityCacheProviderCollectionNode)hierarchy.FindNodeByType(typeof(SecurityCacheProviderCollectionNode));

            foreach (SecurityCacheProviderNode cacheProviderNode in securityCacheCollectionNode.Nodes)
            {
                securityConfiguration.SecurityCacheProviders.Add(cacheProviderNode.SecurityCacheProviderData);
            }
        }
Example #11
0
        private T GetChildNode <T>(ConfigurationNode parentNode) where T : ConfigurationNode
        {
            T childNode = hierarchy.FindNodeByType(parentNode, typeof(T)) as T;

            return(childNode);
        }