Beispiel #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(DynamicQuerySettings.SectionName))
            {
                DynamicQuerySettingsNode dynamicQuerySettingsNode = null;
                try
                {
                    IUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);
                    dynamicQuerySettingsNode = hierarchy.FindNodeByType(typeof(DynamicQuerySettingsNode)) as DynamicQuerySettingsNode;
                    if (dynamicQuerySettingsNode == null)
                    {
                        return;
                    }
                    DynamicQuerySettings dynamicQuerySettings = dynamicQuerySettingsNode.DynamicQuerySettings;
                    configurationContext.WriteConfiguration(DynamicQuerySettings.SectionName, dynamicQuerySettings);
                }
                catch (ConfigurationException e)
                {
                    ServiceHelper.LogError(serviceProvider, dynamicQuerySettingsNode, e);
                }
                catch (InvalidOperationException e)
                {
                    ServiceHelper.LogError(serviceProvider, dynamicQuerySettingsNode, e);
                }
            }
        }
Beispiel #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)
        {
            DynamicQuerySettingsNode node = GetDynamicQuerySettingsNode(serviceProvider);

            if (node != null)
            {
                DynamicQuerySettings settings = node.DynamicQuerySettings;
                configurationDictionary[DynamicQuerySettings.SectionName] = settings;
            }
        }
Beispiel #3
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(DynamicQuerySettings.SectionName))
            {
                DynamicQuerySettings     dynamicQuerySettings     = null;
                DynamicQuerySettingsNode dynamicQuerySettingsNode = null;
                try
                {
                    dynamicQuerySettings     = configurationContext.GetConfiguration(DynamicQuerySettings.SectionName) as DynamicQuerySettings;
                    dynamicQuerySettingsNode = new DynamicQuerySettingsNode(dynamicQuerySettings);
                    ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider);
                    configurationNode.Nodes.Add(dynamicQuerySettingsNode);
                }
                catch (ConfigurationException e)
                {
                    ServiceHelper.LogError(serviceProvider, dynamicQuerySettingsNode, e);
                }
            }
        }