本文整理汇总了C#中System.Configuration.ConnectionStringsSection类的典型用法代码示例。如果您正苦于以下问题:C# ConnectionStringsSection类的具体用法?C# ConnectionStringsSection怎么用?C# ConnectionStringsSection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionStringsSection类属于System.Configuration命名空间,在下文中一共展示了ConnectionStringsSection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectionStringsSectionNodeBuilder
public ConnectionStringsSectionNodeBuilder(IServiceProvider serviceProvider, ConnectionStringsSection conectionStringsSection, string defaultDatabaseName, DatabaseSectionNode databaseSectionNode)
: base(serviceProvider)
{
this.connectionStringSections = conectionStringsSection;
this.databaseSectionNode = databaseSectionNode;
this.defaultDatabaseName = defaultDatabaseName;
}
示例2: SkipsConnectionStringsWithoutProviderNamesOrWithProviderNamesWhichDoNotMapToAProviderFactory
public void SkipsConnectionStringsWithoutProviderNamesOrWithProviderNamesWhichDoNotMapToAProviderFactory()
{
DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();
ConnectionStringsSection section = new ConnectionStringsSection();
section.ConnectionStrings.Add(new ConnectionStringSettings("cs1", "cs1", "System.Data.SqlClient"));
section.ConnectionStrings.Add(new ConnectionStringSettings("cs2", "cs2"));
section.ConnectionStrings.Add(new ConnectionStringSettings("cs3", "cs3", "a bogus provider name"));
section.ConnectionStrings.Add(new ConnectionStringSettings("cs4", "cs4", "System.Data.SqlClient"));
configurationSource.Add("connectionStrings", section);
var factory = new DatabaseProviderFactory(configurationSource.GetSection);
Assert.AreEqual("cs1", factory.Create("cs1").ConnectionString);
Assert.AreEqual("cs4", factory.Create("cs4").ConnectionString);
try
{
factory.Create("cs2");
Assert.Fail("should have thrown");
}
catch (InvalidOperationException)
{
// expected, connection string is ignored
}
try
{
factory.Create("cs3");
Assert.Fail("should have thrown");
}
catch (InvalidOperationException)
{
// expected, connection string is ignored
}
}
示例3: GetConnectionStringsSection
static ConnectionStringsSection GetConnectionStringsSection()
{
ConnectionStringsSection section = new ConnectionStringsSection();
ConnectionStringSettings connectionStringSettings = new ConnectionStringSettings(instanceName, connectionString, providerName);
section.ConnectionStrings.Add(connectionStringSettings);
return section;
}
示例4: AddTo
public void AddTo(ConnectionStringsSection section)
{
var setting = new ConnectionStringSettings(settings.Name,
settings.ConnectionString, settings.ProviderName);
section.ConnectionStrings.Add(setting);
}
示例5: SetupProperties
/// <summary>Sets properties configuration dictionary based on configuration in the database section.</summary>
/// <param name="config">The database section configuration.</param>
/// <param name="connectionStrings">Connection strings from configuration</param>
protected void SetupProperties(DatabaseSection config, ConnectionStringsSection connectionStrings)
{
NHibernate.Cfg.Environment.UseReflectionOptimizer = Utility.GetTrustLevel() > System.Web.AspNetHostingPermissionLevel.Medium;
// connection
Properties[NHibernate.Cfg.Environment.ConnectionStringName] = config.ConnectionStringName;
Properties[NHibernate.Cfg.Environment.ConnectionProvider] = "NHibernate.Connection.DriverConnectionProvider";
Properties[NHibernate.Cfg.Environment.Hbm2ddlKeyWords] = "none";
SetupFlavourProperties(config, connectionStrings);
bool useNonBatcher =
// configured batch size <= 1
(batchSize.HasValue && batchSize.Value <= 1)
// medium trust in combination with sql client driver
// causes fault: Attempt by method 'NHibernate.AdoNet.SqlClientSqlCommandSet..ctor()' to access method 'System.Data.SqlClient.SqlCommandSet..ctor()' failed. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
|| (Utility.GetTrustLevel() <= System.Web.AspNetHostingPermissionLevel.Medium && typeof(SqlClientDriver).IsAssignableFrom(Type.GetType(Properties[Environment.ConnectionDriver])));
if (useNonBatcher)
Properties[NHibernate.Cfg.Environment.BatchStrategy] = typeof(NonBatchingBatcherFactory).AssemblyQualifiedName;
SetupCacheProperties(config);
if (config.Isolation.HasValue)
Properties[NHibernate.Cfg.Environment.Isolation] = config.Isolation.ToString();
foreach (string key in config.HibernateProperties.AllKeys)
{
Properties[key] = config.HibernateProperties[key].Value;
}
}
示例6: SetUp
public void SetUp()
{
loggingSettings = new LoggingSettings();
connectionStringsSection = new ConnectionStringsSection();
configurationSource = new DictionaryConfigurationSource();
configurationSource.Add(LoggingSettings.SectionName, loggingSettings);
configurationSource.Add("connectionStrings", connectionStringsSection);
}
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:8,代码来源:FormattedDatabaseTraceListenerPolicyCreatorFixture.cs
示例7: GenerateConnectionStringSection
private static ConnectionStringsSection GenerateConnectionStringSection()
{
ConnectionStringsSection section = new ConnectionStringsSection();
section.ConnectionStrings.Add(new ConnectionStringSettings("Service_Dflt", "Data Source=ORACLE82;User id=system;Password=aaaabbbccc;", "Oracle.DataAccess.Client"));
section.ConnectionStrings.Add(new ConnectionStringSettings("NewDatabase", "Data Source=XE;User id=system;Password=admin;", "Oracle.DataAccess.Client"));
section.ConnectionStrings.Add(new ConnectionStringSettings("DbWithOracleAuthn", "Data Source=XE;User id=system;Password=admin;", "Oracle.DataAccess.Client"));
section.ConnectionStrings.Add(new ConnectionStringSettings("NwindPersistFalse", "Data Source=XE;User id=system;Password=admin;Persist Security Info=false;", "Oracle.DataAccess.Client"));
return section;
}
示例8: Build
public ConnectionStringsSection Build()
{
connectionStringsSection = new ConnectionStringsSection();
foreach (ConnectionStringSettingsNode node in connectionStringsSectionNode.Nodes)
{
BuildConnectionString(node);
}
return connectionStringsSection;
}
示例9: Reload
public static void Reload()
{
Config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
ConnectionStringsSection = Config.GetSection("userConnectionStrings") as System.Configuration.ConnectionStringsSection;
if (ConnectionStringsSection == null)
{
ConnectionStringsSection = new System.Configuration.ConnectionStringsSection();
ConnectionStringsSection.SectionInformation.set_AllowExeDefinition(ConfigurationAllowExeDefinition.MachineToLocalUser);
Config.Sections.Add("userConnectionStrings", ConnectionStringsSection);
Config.Save();
}
}
示例10: DBInfo
/// <summary>
/// Initializes a new instance of the <see cref="DBInfo"/> class.
/// </summary>
/// <param name="connectionStringSettings">
/// The db connection settings
/// </param>
public DBInfo(string connectionString)
{
if (string.IsNullOrEmpty(connectionString))
throw new ArgumentNullException("connectionStringSettings");
DictionaryConfigurationSource source = new DictionaryConfigurationSource();
ConnectionStringSettings connectionStringSettings = new ConnectionStringSettings(Constants.ConnectionStringSettingsName, connectionString, Constants.SystemDataSqlite);
ConnectionStringsSection section = new ConnectionStringsSection();
section.ConnectionStrings.Add(connectionStringSettings);
source.Add("connectionStrings", section);
this._database = new DatabaseProviderFactory(source).Create(connectionStringSettings.Name);
this.CreateConnection();
}
示例11: ConnectionStringsSection
void IAddTo.AddTo(IConfigurationSource configurationSource)
{
var section = new ConnectionStringsSection();
foreach(var builder in builders)
{
builder.AddTo(section);
}
configurationSource.Add("connectionStrings", section);
var databaseSettings = new DatabaseSettings {DefaultDatabase = defaultDatabase};
configurationSource.Add(DatabaseSettings.SectionName, databaseSettings);
}
示例12: Given
public void Given()
{
configurationSource = new DictionaryConfigurationSource();
var connectionStringsSection = new ConnectionStringsSection();
connectionStringsSection.ConnectionStrings.Add(
new ConnectionStringSettings
{
Name = "odbc connection",
ConnectionString = "connection string",
ProviderName = "System.Data.Odbc"
});
configurationSource.Add("connectionStrings", connectionStringsSection);
settings = new DatabaseSyntheticConfigSettings(configurationSource.GetSection);
}
示例13: CreateConfigurationSource
public static DictionaryConfigurationSource CreateConfigurationSource()
{
DictionaryConfigurationSource source = new DictionaryConfigurationSource();
DatabaseSettings settings = new DatabaseSettings();
settings.DefaultDatabase = "SqlCeTestConnection";
ConnectionStringsSection section = new ConnectionStringsSection();
section.ConnectionStrings.Add(new ConnectionStringSettings("SqlCeTestConnection", "Data Source='testdb.sdf'", "System.Data.SqlServerCe.3.5"));
source.Add(DatabaseSettings.SectionName, settings);
source.Add("connectionStrings", section);
return source;
}
示例14: CreateConfigurationSource
public static DictionaryConfigurationSource CreateConfigurationSource()
{
DictionaryConfigurationSource configSource = TestConfigurationSource.CreateConfigurationSource();
var connectionString = new ConnectionStringSettings(
OracleConnectionStringName,
OracleConnectionString,
OracleProviderName);
var connectionStrings = new ConnectionStringsSection();
connectionStrings.ConnectionStrings.Add(connectionString);
configSource.Add("connectionStrings", connectionStrings);
return configSource;
}
开发者ID:VAllens,项目名称:EntLibContrib.Data.Oracle.ManagedDataAccess,代码行数:15,代码来源:OracleTestConfigurationSource.cs
示例15: Act
protected override void Act()
{
var section = new ConnectionStringsSection();
source = new DesignDictionaryConfigurationSource();
source.Add("connectionStrings", section);
var configurationSection = source.GetSection(DataAccessDesignTime.ConnectionStringSettingsSectionName);
var configurationSourceModel = Container.Resolve<ConfigurationSourceModel>();
configurationSourceModel.Load(source);
var databaseSectionViewModel = configurationSourceModel.Sections
.Where(x => x.SectionName == DataAccessDesignTime.ConnectionStringSettingsSectionName)
.Single();
databaseSectionViewModel.Save(source);
}