예제 #1
0
        /// <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 void Save(IServiceProvider serviceProvider)
        {
            ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider);

            if (configurationContext.IsValidSection(DatabaseSettings.SectionName))
            {
                DatabaseSettingsNode databaseSettingsNode = null;
                try
                {
                    IUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);
                    databaseSettingsNode = hierarchy.FindNodeByType(typeof(DatabaseSettingsNode)) as DatabaseSettingsNode;
                    if (databaseSettingsNode == null)
                    {
                        return;
                    }
                    DatabaseSettings databaseSettings = databaseSettingsNode.DatabaseSettings;
                    configurationContext.WriteConfiguration(DatabaseSettings.SectionName, databaseSettings);
                }
                catch (ConfigurationException e)
                {
                    ServiceHelper.LogError(serviceProvider, databaseSettingsNode, e);
                }
                catch (InvalidOperationException e)
                {
                    ServiceHelper.LogError(serviceProvider, databaseSettingsNode, e);
                }
            }
        }
예제 #2
0
        /// <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 void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary)
        {
            DatabaseSettingsNode node = GetDatabaseSettingsNode(serviceProvider);

            if (node != null)
            {
                DatabaseSettings settings = node.DatabaseSettings;
                configurationDictionary[DatabaseSettings.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 void Open(IServiceProvider serviceProvider)
 {
     ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider);
     if (configurationContext.IsValidSection(DatabaseSettings.SectionName))
     {
         DatabaseSettings databaseSettings = null;
         DatabaseSettingsNode databaseSettingsNode = null;
         try
         {
             databaseSettings = (DatabaseSettings)configurationContext.GetConfiguration(DatabaseSettings.SectionName);
             databaseSettingsNode = new DatabaseSettingsNode(databaseSettings);
             ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider);
             configurationNode.Nodes.Add(databaseSettingsNode);
         }
         catch (ConfigurationException e)
         {
             ServiceHelper.LogError(serviceProvider, databaseSettingsNode, e);
         }
     }
 }
예제 #4
0
        /// <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 void Open(IServiceProvider serviceProvider)
        {
            ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider);

            if (configurationContext.IsValidSection(DatabaseSettings.SectionName))
            {
                DatabaseSettings     databaseSettings     = null;
                DatabaseSettingsNode databaseSettingsNode = null;
                try
                {
                    databaseSettings     = (DatabaseSettings)configurationContext.GetConfiguration(DatabaseSettings.SectionName);
                    databaseSettingsNode = new DatabaseSettingsNode(databaseSettings);
                    ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider);
                    configurationNode.Nodes.Add(databaseSettingsNode);
                }
                catch (ConfigurationException e)
                {
                    ServiceHelper.LogError(serviceProvider, databaseSettingsNode, e);
                }
            }
        }