本文整理汇总了C#中System.Configuration.ConnectionStringsSection类的典型用法代码示例。如果您正苦于以下问题:C# ConnectionStringsSection类的具体用法?C# ConnectionStringsSection怎么用?C# ConnectionStringsSection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionStringsSection类属于System.Configuration命名空间,在下文中一共展示了ConnectionStringsSection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ConnectionStringsSectionNodeBuilder
public ConnectionStringsSectionNodeBuilder(IServiceProvider serviceProvider, ConnectionStringsSection conectionStringsSection, string defaultDatabaseName, DatabaseSectionNode databaseSectionNode)
: base(serviceProvider)
{
this.connectionStringSections = conectionStringsSection;
this.databaseSectionNode = databaseSectionNode;
this.defaultDatabaseName = defaultDatabaseName;
}
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:7,代码来源:ConnectionStringsSectionNodeBuilder.cs
示例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
}
}
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:34,代码来源:DatabaseProviderFactoryFixture.cs
示例3: GetConnectionStringsSection
static ConnectionStringsSection GetConnectionStringsSection()
{
ConnectionStringsSection section = new ConnectionStringsSection();
ConnectionStringSettings connectionStringSettings = new ConnectionStringSettings(instanceName, connectionString, providerName);
section.ConnectionStrings.Add(connectionStringSettings);
return section;
}
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:7,代码来源:SqlCeDatabaseFixture.cs
示例4: AddTo
public void AddTo(ConnectionStringsSection section)
{
var setting = new ConnectionStringSettings(settings.Name,
settings.ConnectionString, settings.ProviderName);
section.ConnectionStrings.Add(setting);
}
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:7,代码来源:ConnectionStringsSectionBuilder.cs
示例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;
}
}
开发者ID:nagarjunachallapalli,项目名称:n2cms,代码行数:34,代码来源:ConfigurationBuilder.cs
示例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;
}
开发者ID:liujiekm,项目名称:MedicalInsuranceService,代码行数:9,代码来源:ConfigurationSource.cs
示例8: Build
public ConnectionStringsSection Build()
{
connectionStringsSection = new ConnectionStringsSection();
foreach (ConnectionStringSettingsNode node in connectionStringsSectionNode.Nodes)
{
BuildConnectionString(node);
}
return connectionStringsSection;
}
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:9,代码来源:ConnectionStringsSectionBuilder.cs
示例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();
}
}
开发者ID:u4097,项目名称:SQLScript,代码行数:12,代码来源:ConnectionsConfigurator.cs
示例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();
}
开发者ID:alcardac,项目名称:SDMX_DATA_BROWSER,代码行数:19,代码来源:DBInfo.cs
示例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);
}
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:13,代码来源:ConnectionStringsSectionBuilder.cs
示例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);
}
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:15,代码来源:DataAccessTypeRegistrationFixture.cs
示例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;
}
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:15,代码来源:TestConfigurationSource.cs
示例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);
}
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:16,代码来源:when_saving_empty_data_configuration_section.cs
示例16: ConfigurationBuilder
/// <summary>Creates a new instance of the <see cref="ConfigurationBuilder"/>.</summary>
public ConfigurationBuilder(IDefinitionProvider[] definitionProviders, ClassMappingGenerator generator, IWebContext webContext, ConfigurationBuilderParticipator[] participators, DatabaseSection config, ConnectionStringsSection connectionStrings)
{
this.definitionProviders = definitionProviders;
this.generator = generator;
this.webContext = webContext;
this.participators = participators;
if (config == null) config = new DatabaseSection();
TryLocatingHbmResources = config.TryLocatingHbmResources;
tablePrefix = config.TablePrefix;
batchSize = config.BatchSize;
childrenLaziness = config.ChildrenLaziness;
SetupProperties(config, connectionStrings);
SetupMappings(config);
}
开发者ID:ikvm,项目名称:n2cms,代码行数:17,代码来源:ConfigurationBuilder.cs
示例17: SqlConnectionStringBuilder
public Configuracoes mudaConfigurações()
{
SqlConnectionStringBuilder myCSB = new SqlConnectionStringBuilder();
ConnectionStringsSection csSection = new ConnectionStringsSection();
#region Implementação
myCSB.DataSource = config.Servidor;
myCSB.InitialCatalog = config.Database;
myCSB.UserID = config.User;
myCSB.Password = config.Senha;
config.ConectionString = myCSB.ConnectionString;
return config;
#endregion
}
开发者ID:ViniciusConsultor,项目名称:sistema-estoque,代码行数:18,代码来源:frmConfiguracao.cs
示例18: ConfigurationBuilder
/// <summary>Creates a new instance of the <see cref="ConfigurationBuilder"/>.</summary>
public ConfigurationBuilder(IDefinitionManager definitions, ClassMappingGenerator generator, DatabaseSection config, ConnectionStringsSection connectionStrings)
{
this.definitions = definitions;
this.generator = generator;
if (config == null) config = new DatabaseSection();
if (!string.IsNullOrEmpty(config.HibernateMapping))
DefaultMapping = config.HibernateMapping;
SetupProperties(config, connectionStrings);
SetupMappings(config);
TryLocatingHbmResources = config.TryLocatingHbmResources;
tablePrefix = config.TablePrefix;
batchSize = config.BatchSize;
childrenLaziness = config.ChildrenLaziness;
}
开发者ID:spmason,项目名称:n2cms,代码行数:19,代码来源:ConfigurationBuilder.cs
示例19: ClassModConfig
//##### INICIALIZA LOS DATOS DEL APPCONFIG #####
public ClassModConfig()
{
try
{
MiAppConfig = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath); //Se abre el app.config
CadenaConexion = (ConnectionStringsSection)MiAppConfig.GetSection("connectionStrings"); //Obtengo la cadena de conexion
MiConfig = (AppSettingsSection)MiAppConfig.GetSection("appSettings"); //Obtengo la seccion appSettings
MiCnx = ConfigurationManager.ConnectionStrings["EnterpriseSolution.Properties.Settings.bdnominaConnectionString"]; //capturo cadena de conexion
Estado = ConfigurationManager.AppSettings["Validador"];
Licencia = ConfigurationManager.AppSettings["Licencia"];
InfEmp = ConfigurationManager.AppSettings["InfEmp"];
Skins = ConfigurationManager.AppSettings["Skins"];
Update = ConfigurationManager.AppSettings["Update"];
}
catch (Exception ex)
{
MsjErr.MsjBox(1, "ERR001-01", "No se pueden leer todos los valores del app.config - " + ex.ToString());
Environment.Exit(0);
}
}
开发者ID:aortega02,项目名称:EnterpriseSolution,代码行数:22,代码来源:ClassModConfig.cs
示例20: Create
public virtual object Create (object parent, object configContext, XmlNode section)
{
ConnectionStringsSection csSection = new ConnectionStringsSection ();
ConnectionStringSettingsCollection csList = csSection.ConnectionStrings;
foreach (XmlNode addNode in section.SelectNodes (".//add")) {
if (addNode.NodeType != XmlNodeType.Element)
continue;
string name;
string providerName;
string connectionString;
name = GetAttributeValue (addNode, "name");
providerName = GetAttributeValue (addNode, "providerName");
connectionString = GetAttributeValue (addNode, "connectionString");
ConnectionStringSettings cs = new ConnectionStringSettings (name, connectionString, providerName);
csList.Add (cs);
}
return csSection;
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:22,代码来源:ConnectionStringsSectionHandler.cs
注:本文中的System.Configuration.ConnectionStringsSection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论