Esempio n. 1
0
 internal SqlInternalConnectionSmi(SqlConnectionString connectionOptions, SmiContext smiContext) : base(connectionOptions)
 {
     this._smiContext             = smiContext;
     this._smiContext.OutOfScope += new EventHandler(this.OnOutOfScope);
     this._smiConnection          = this._smiContext.ContextConnection;
     this._smiEventSink           = new EventSink(this);
     if (Bid.AdvancedOn)
     {
         Bid.Trace("<sc.SqlInternalConnectionSmi.ctor|ADV> %d#, constructed new SMI internal connection\n", base.ObjectID);
     }
 }
Esempio n. 2
0
        internal SqlInternalConnectionSmi(SqlConnectionString connectionOptions, SmiContext smiContext) : base(connectionOptions)
        {
            Debug.Assert(null != smiContext, "null smiContext?");

            _smiContext             = smiContext;
            _smiContext.OutOfScope += new EventHandler(OnOutOfScope);

            _smiConnection = _smiContext.ContextConnection;
            Debug.Assert(null != _smiConnection, "null SmiContext.ContextConnection?");

            _smiEventSink = new EventSink(this);
            SqlClientEventSource.Log.AdvanceTrace("<sc.SqlInternalConnectionSmi.ctor|ADV> {0}#, constructed new SMI internal connection", ObjectID);
        }
        private SqlInternalConnectionSmi GetContextConnection(SqlConnectionString options, object providerInfo, DbConnection owningConnection)
        {
            SmiContext currentContext             = SmiContextFactory.Instance.GetCurrentContext();
            SqlInternalConnectionSmi contextValue = (SqlInternalConnectionSmi)currentContext.GetContextValue(0);

            if ((contextValue == null) || contextValue.IsConnectionDoomed)
            {
                if (contextValue != null)
                {
                    contextValue.Dispose();
                }
                contextValue = new SqlInternalConnectionSmi(options, currentContext);
                currentContext.SetContextValue(0, contextValue);
            }
            contextValue.Activate();
            return(contextValue);
        }
Esempio n. 4
0
        private SqlInternalConnectionSmi GetContextConnection(SqlConnectionString options, object providerInfo)
        {
            SmiContext smiContext = SmiContextFactory.Instance.GetCurrentContext();

            SqlInternalConnectionSmi result = (SqlInternalConnectionSmi)smiContext.GetContextValue((int)SmiContextFactory.ContextKey.Connection);

            // context connections are automatically re-useable if they exist unless they've been doomed.
            if (null == result || result.IsConnectionDoomed)
            {
                if (null != result)
                {
                    result.Dispose();   // A doomed connection is a messy thing.  Dispose of it promptly in nearest receptacle.
                }

                result = new SqlInternalConnectionSmi(options, smiContext);
                smiContext.SetContextValue((int)SmiContextFactory.ContextKey.Connection, result);
            }

            result.Activate();

            return(result);
        }
Esempio n. 5
0
 public SmiIdentity(SmiContext context)
 {
     _db = context;
 }