public void ClientSettingsDefaultChildNodesTest() { ClientSettingsNode node = new ClientSettingsNode(); GeneratedApplicationNode.Nodes.AddWithDefaultChildren(node); Assert.AreEqual(1, node.Nodes.Count); Assert.AreEqual(typeof(DistributionStrategyCollectionNode), node.Nodes[0].GetType()); }
/// <summary> /// <para>Saves the configuration settings created for the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public override void Save(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(LoggingSettings.SectionName)) { ClientSettingsNode clientSettingsNode = null; try { IUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider); clientSettingsNode = hierarchy.FindNodeByType(typeof(ClientSettingsNode)) as ClientSettingsNode; if (clientSettingsNode == null) { return; } LoggingSettings loggingSettings = clientSettingsNode.LoggingSettings; configurationContext.WriteConfiguration(LoggingSettings.SectionName, loggingSettings); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, clientSettingsNode, e); } catch (InvalidOperationException e) { ServiceHelper.LogError(serviceProvider, clientSettingsNode, e); } } }
public void ClientSettingsDataTest() { DistributionStrategyDataCollection distStrategies = new DistributionStrategyDataCollection(); DistributionStrategyData distData = new InProcDistributionStrategyData(); distData.Name = "Test"; distStrategies.Add(distData); LoggingSettings settings = new LoggingSettings(); settings.CategoryFilterMode = CategoryFilterMode.DenyAllExceptAllowed; settings.CategoryFilters = new CategoryFilterDataCollection(); foreach (DistributionStrategyData distributionStrategyData in distStrategies) { settings.DistributionStrategies.Add(distributionStrategyData); } settings.LoggingEnabled = true; settings.MinimumPriority = 0; settings.TracingEnabled = true; ClientSettingsNode node = new ClientSettingsNode(settings); GeneratedApplicationNode.Nodes.Add(node); Assert.AreEqual(CategoryFilterMode.DenyAllExceptAllowed, node.CategoryFilterSettings.CategoryFilterMode); Assert.AreEqual(0, node.CategoryFilterSettings.CategoryFilters.Count); Assert.AreEqual(true, node.LoggingEnabled); Assert.AreEqual(0, node.MinimumPriority); Assert.AreEqual(true, node.TracingEnabled); LoggingSettings nodeData = node.LoggingSettings; Assert.AreEqual(CategoryFilterMode.DenyAllExceptAllowed, nodeData.CategoryFilterMode); Assert.AreEqual(0, nodeData.CategoryFilters.Count); Assert.AreEqual("Test", nodeData.DistributionStrategies["Test"].Name); Assert.AreEqual(true, nodeData.LoggingEnabled); Assert.AreEqual(0, nodeData.MinimumPriority); Assert.AreEqual(true, nodeData.TracingEnabled); }
/// <summary> /// <para>Adds to the dictionary configuration data for /// the enterpriselibrary.configurationSettings configuration section.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <param name="configurationDictionary"> /// <para>A <see cref="ConfigurationDictionary"/> to add /// configuration data to.</para></param> public override void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary) { ClientSettingsNode node = GetClientSettingsNode(serviceProvider); if (node != null) { LoggingSettings settings = node.LoggingSettings; configurationDictionary[LoggingSettings.SectionName] = settings; } }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public override void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(LoggingSettings.SectionName)) { LoggingSettings loggingSettings = null; ClientSettingsNode clientSettingsNode = null; try { loggingSettings = (LoggingSettings)configurationContext.GetConfiguration(LoggingSettings.SectionName); clientSettingsNode = new ClientSettingsNode(loggingSettings); ConfigurationNode configurationNode = GetLoggingSettingsNode(serviceProvider); configurationNode.Nodes.Add(clientSettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, clientSettingsNode, e); } } }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public override void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(LoggingSettings.SectionName)) { LoggingSettings loggingSettings = null; ClientSettingsNode clientSettingsNode = null; try { loggingSettings = (LoggingSettings)configurationContext.GetConfiguration(LoggingSettings.SectionName); clientSettingsNode = new ClientSettingsNode(loggingSettings); ConfigurationNode configurationNode = GetLoggingSettingsNode(serviceProvider); configurationNode.Nodes.Add(clientSettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, clientSettingsNode, e); } } }
private void InitializeDialog(CategoryFilterEditorUI dialog, ClientSettingsNode node) { dialog.FilterMode = node.CategoryFilterSettings.CategoryFilterMode; SetCategoryFilterSettings(dialog, node); SetAvailableCategoryNames(dialog, node); }
private void SetCategoryFilterSettings(CategoryFilterEditorUI dialog, ClientSettingsNode node) { ArrayList selectedCategoryNames = new ArrayList(); foreach (CategoryFilterData categoryFilter in node.CategoryFilterSettings.CategoryFilters) { selectedCategoryNames.Add(categoryFilter.Name); } dialog.SetSelectedCategoryNames(selectedCategoryNames); }
public void ClientSettingsNodeTest() { DistributionStrategyNode distributionStrategy = new InProcDistributionStrategyNode(); bool loggingEnabled = true; int minimumPriority = 1; bool tracingEnabled = true; ClientSettingsNode node = new ClientSettingsNode(); GeneratedApplicationNode.Nodes.Add(node); node.CategoryFilterSettings = new CategoryFilterSettings(CategoryFilterMode.DenyAllExceptAllowed, new CategoryFilterDataCollection()); node.DistributionStrategy = distributionStrategy; node.LoggingEnabled = loggingEnabled; node.MinimumPriority = minimumPriority; node.TracingEnabled = tracingEnabled; Assert.AreEqual(CategoryFilterMode.DenyAllExceptAllowed, node.CategoryFilterSettings.CategoryFilterMode); Assert.AreEqual(distributionStrategy, node.DistributionStrategy); Assert.AreEqual(loggingEnabled, node.LoggingEnabled); Assert.AreEqual(minimumPriority, node.MinimumPriority); Assert.AreEqual(tracingEnabled, tracingEnabled); }
public void RuntimeTest() { GeneratedHierarchy.Open(); Assert.AreEqual(0, ConfigurationErrorsCount); ConfigurationContext configurationContext = GeneratedHierarchy.ConfigurationContext; if (configurationContext.IsValidSection(LoggingSettings.SectionName)) { LoggingSettings clientSettings = configurationContext.GetConfiguration(LoggingSettings.SectionName) as LoggingSettings; if (clientSettings != null) { ClientSettingsNode settingsNode = new ClientSettingsNode(clientSettings); Assert.AreEqual(CategoryFilterMode.DenyAllExceptAllowed, settingsNode.CategoryFilterSettings.CategoryFilterMode); Assert.AreEqual(false, settingsNode.LoggingEnabled); Assert.AreEqual(1, settingsNode.MinimumPriority); Assert.AreEqual(false, settingsNode.TracingEnabled); } } else { Assert.Fail(String.Format("Can not load section: {0}", LoggingSettings.SectionName)); } }
public void DesigntimeTest() { LoggingSettings settings = ConfigurationManager.GetConfiguration(LoggingSettings.SectionName) as LoggingSettings; Assert.IsNotNull(settings); ClientSettingsNode settingsNode = new ClientSettingsNode(settings); GeneratedApplicationNode.Nodes.Add(settingsNode); Assert.AreEqual(settings.CategoryFilterMode, settingsNode.CategoryFilterSettings.CategoryFilterMode); Assert.AreEqual(settings.LoggingEnabled, settingsNode.LoggingEnabled); Assert.AreEqual(settings.MinimumPriority, settingsNode.MinimumPriority); Assert.AreEqual(settings.Name, settingsNode.Name); Assert.AreEqual(settings.TracingEnabled, settingsNode.TracingEnabled); }