public void ExectueAddsDefaultNodes()
		{
			AddDatabaseSectionNodeCommand cmd = new AddDatabaseSectionNodeCommand(ServiceProvider);
			cmd.Execute(ApplicationNode);

			Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);

			ConnectionStringSettingsNode connectionStringNode = (ConnectionStringSettingsNode)Hierarchy.FindNodeByType(typeof(ConnectionStringSettingsNode));
			AddOracleConnectionElementNodeCommand oracleCmd = new AddOracleConnectionElementNodeCommand(ServiceProvider);
			oracleCmd.Execute(connectionStringNode);

			Assert.IsNotNull(Hierarchy.FindNodeByType(connectionStringNode, typeof(OracleConnectionElementNode)));
		}		
		/// <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());
			}
		}
        public void ExectueAddsDefaultNodes()
        {
            AddDatabaseSectionNodeCommand cmd = new AddDatabaseSectionNodeCommand(ServiceProvider);
            cmd.Execute(ApplicationNode);

            Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount);

            ConfigurationNode node = Hierarchy.FindNodeByType(typeof(DatabaseSectionNode));
            Assert.IsNotNull(node);

            node = Hierarchy.FindNodeByType(typeof(ConnectionStringSettingsNode));
            Assert.IsNotNull(node);

            IList<ConfigurationNode> nodes = Hierarchy.FindNodesByType(typeof(ParameterNode));
            Assert.AreEqual(3, nodes.Count);

            node = Hierarchy.FindNodeByType(typeof(ProviderMappingsNode));
            Assert.IsNotNull(node);
        }
Example #4
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());
     }
 }