當前位置: 首頁>>代碼示例>>C#>>正文


C# Configuration.ConnectionStringsSection類代碼示例

本文整理匯總了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;
		}
開發者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


注:本文中的System.Configuration.ConnectionStringsSection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。