public DatabaseSectionNode Build()
 {
     DatabaseSectionNode node = new DatabaseSectionNode();
     ProviderMappingsNode mappingsNode = new ProviderMappingsNode();
     foreach (DbProviderMapping mapping in databaseSettings.ProviderMappings)
     {
         mappingsNode.AddNode(new ProviderMappingNode(mapping));
     }
     node.AddNode(mappingsNode);
     return node;
 }
Example #2
0
        public DatabaseSectionNode Build()
        {
            DatabaseSectionNode  node         = new DatabaseSectionNode();
            ProviderMappingsNode mappingsNode = new ProviderMappingsNode();

            foreach (DbProviderMapping mapping in databaseSettings.ProviderMappings)
            {
                mappingsNode.AddNode(new ProviderMappingNode(mapping));
            }
            node.AddNode(mappingsNode);
            return(node);
        }
Example #3
0
        public DatabaseSectionNode Build()
        {
            DatabaseSectionNode  node         = new DatabaseSectionNode();
            ProviderMappingsNode mappingsNode = new ProviderMappingsNode();

            foreach (DbProviderMapping mapping in databaseSettings.ProviderMappings)
            {
                mappingsNode.AddNode(new ProviderMappingNode(mapping));
            }
            node.AddNode(mappingsNode);
            node.RequirePermission = databaseSettings.SectionInformation.RequirePermission;
            return(node);
        }
Example #4
0
        protected override void OnExecuted(EventArgs e)
        {
            DatabaseSectionNode node = ChildNode as DatabaseSectionNode;

            Debug.Assert(null != node, "Expected DatabaseSectionNode");
            if (addDefaultConnectionString)
            {
                new AddConnectionStringsSectionNodeCommand(ServiceProvider).Execute(node);
                ConnectionStringSettingsNode defaultDatabaseNode = (ConnectionStringSettingsNode)CurrentHierarchy.FindNodeByType(node, typeof(ConnectionStringSettingsNode));
                node.DefaultDatabase = defaultDatabaseNode;
            }
            node.AddNode(new ProviderMappingsNode());
        }
Example #5
0
 /// <summary>
 /// Opens the connection strings section, builds the design time nodes and adds them to the application node.
 /// </summary>
 /// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
 /// <param name="rootNode">The root node of the application.</param>
 /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param>
 protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
 {
     if (null != section)
     {
         string           defaultDatabase = string.Empty;
         DatabaseSettings databaseSection = DatabaseSettings.GetDatabaseSettings(GetConfigurationSource(serviceProvider));
         if (null != databaseSection)
         {
             defaultDatabase = databaseSection.DefaultDatabase;
         }
         DatabaseSectionNode node = rootNode.Hierarchy.FindNodeByType(typeof(DatabaseSectionNode)) as DatabaseSectionNode;
         if (null == node)
         {
             AddDatabaseSectionNodeCommand dbCmd = new AddDatabaseSectionNodeCommand(serviceProvider, false);
             dbCmd.Execute(rootNode);
             node = dbCmd.ChildNode as DatabaseSectionNode;
             Debug.Assert(node != null);
         }
         ConnectionStringsSectionNodeBuilder builder = new ConnectionStringsSectionNodeBuilder(serviceProvider, (ConnectionStringsSection)section, defaultDatabase, node);
         node.AddNode(builder.Build());
     }
 }