|
//===============================================================================
// Microsoft patterns & practices Enterprise Library
// Data Access Application Block
//===============================================================================
// Copyright � Microsoft Corporation. All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
using System;using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;
using System.Configuration;
namespace Microsoft.Practices.EnterpriseLibrary.Data.Configuration.Design
{
sealed class ConnectionStringsSectionNodeBuilder : NodeBuilder
{
private ConnectionStringsSection connectionStringSections;
private ConnectionStringsSectionNode node;
private DatabaseSectionNode databaseSectionNode;
private string defaultDatabaseName;
public ConnectionStringsSectionNodeBuilder(IServiceProvider serviceProvider, ConnectionStringsSection conectionStringsSection, string defaultDatabaseName, DatabaseSectionNode databaseSectionNode)
: base(serviceProvider)
{
this.connectionStringSections = conectionStringsSection;
this.databaseSectionNode = databaseSectionNode;
this.defaultDatabaseName = defaultDatabaseName;
}
public ConnectionStringsSectionNode Build()
{
node = new ConnectionStringsSectionNode();
foreach (ConnectionStringSettings connectionString in connectionStringSections.ConnectionStrings)
{
BuildConnectionStringNode(connectionString);
}
return node;
}
private void BuildConnectionStringNode(ConnectionStringSettings connectionString)
{
ConnectionStringSettingsNode connectionStringNode = new ConnectionStringSettingsNode(connectionString);
if (connectionStringNode.Name == defaultDatabaseName) databaseSectionNode.DefaultDatabase = connectionStringNode;
node.AddNode(connectionStringNode);
ICollection<ConnectionStringNameValuePair> pairs = ConnectionStringParser.Parse(connectionString.ConnectionString);
foreach (ConnectionStringNameValuePair pair in pairs)
{
connectionStringNode.AddNode(new ParameterNode(pair.Name, pair.Value));
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been a programmer for longer than I care to remember. It all started with those BBC (model B's) at school, it all went down hill from there.....
This year, I am mostly coding in.. C# (WPF & WCF)
Blog Address http://markpm.blogspot.com