コード例 #1
0
ファイル: Database.cs プロジェクト: ChiangHanLung/PIC_VDS
		/// <summary>
		/// Initializes a new instance of the <see cref="Database"/> class with a connection string and a <see cref="DbProviderFactory"/>.
		/// </summary>
		/// <param name="connectionString">The connection string for the database.</param>
		/// <param name="dbProviderFactory">A <see cref="DbProviderFactory"/> object.</param>
		protected Database(string connectionString, DbProviderFactory dbProviderFactory)
		{
			if (string.IsNullOrEmpty(connectionString)) throw new ArgumentException(Resources.ExceptionNullOrEmptyString, "connectionString");
			if (dbProviderFactory == null) throw new ArgumentNullException("dbProviderFactory");

			this.connectionString = new ConnectionString(connectionString, VALID_USER_ID_TOKENS, VALID_PASSWORD_TOKENS);
			this.dbProviderFactory = dbProviderFactory;
			this.instrumentationProvider = new DataInstrumentationProvider();
		}
コード例 #2
0
        /// <summary>
        /// Binds the events exposed by the source to the handlers in the listener.
        /// </summary>
        /// <param name="source">The source of instrumentation events. Must be an instance of <see cref="DataInstrumentationProvider"/>.</param>
        /// <param name="listener">The listener for instrumentation events. Must be an instance of <see cref="DataInstrumentationListener"/>.</param>
        public void Bind(object source, object listener)
        {
            DataInstrumentationListener castedListener = (DataInstrumentationListener)listener;
            DataInstrumentationProvider castedProvider = (DataInstrumentationProvider)source;

            castedProvider.commandExecuted  += castedListener.CommandExecuted;
            castedProvider.commandFailed    += castedListener.CommandFailed;
            castedProvider.connectionFailed += castedListener.ConnectionFailed;
            castedProvider.connectionOpened += castedListener.ConnectionOpened;
        }
コード例 #3
0
ファイル: Database.cs プロジェクト: huaminglee/myyyyshop
 protected Database(string connectionString, System.Data.Common.DbProviderFactory dbProviderFactory)
 {
     if (string.IsNullOrEmpty(connectionString))
     {
         throw new ArgumentException(Resources.ExceptionNullOrEmptyString, "connectionString");
     }
     if (dbProviderFactory == null)
     {
         throw new ArgumentNullException("dbProviderFactory");
     }
     this.connectionString = new Microsoft.Practices.EnterpriseLibrary.Data.ConnectionString(connectionString, VALID_USER_ID_TOKENS, VALID_PASSWORD_TOKENS);
     this.dbProviderFactory = dbProviderFactory;
     this.instrumentationProvider = new DataInstrumentationProvider();
 }