private Keywords GetIndex(string keyword)
        {
            ADP.CheckArgumentNull(keyword, nameof(keyword));
            Keywords index;

            if (s_keywords.TryGetValue(keyword, out index))
            {
                return(index);
            }
            throw UnsupportedKeyword(keyword);
        }
예제 #2
0
        public void ClearPool(DbConnection connection)
        {
            ADP.CheckArgumentNull(connection, nameof(connection));

            DbConnectionPoolGroup poolGroup = GetConnectionPoolGroup(connection);

            if (null != poolGroup)
            {
                poolGroup.Clear();
            }
        }
예제 #3
0
        static public void ClearPool(SqlConnection connection)
        {
            ADP.CheckArgumentNull(connection, "connection");

            DbConnectionOptions connectionOptions = connection.UserConnectionOptions;

            if (null != connectionOptions)
            {
                SqlConnectionFactory.SingletonInstance.ClearPool(connection);
            }
        }
예제 #4
0
        private OdbcParameter(OdbcParameter source) : this()
        {
            ADP.CheckArgumentNull(source, "source");
            source.CloneHelper(this);
            ICloneable cloneable = this._value as ICloneable;

            if (cloneable != null)
            {
                this._value = cloneable.Clone();
            }
        }
예제 #5
0
        public DbMetaDataFactory(Stream xmlStream, string serverVersion, string normalizedServerVersion)
        {
            ADP.CheckArgumentNull(xmlStream, nameof(xmlStream));
            ADP.CheckArgumentNull(serverVersion, nameof(serverVersion));
            ADP.CheckArgumentNull(normalizedServerVersion, nameof(normalizedServerVersion));

            LoadDataSetFromXml(xmlStream);

            _serverVersionString     = serverVersion;
            _normalizedServerVersion = normalizedServerVersion;
        }
예제 #6
0
        public override bool TryGetValue(string keyword, out object value)
        {
            ADP.CheckArgumentNull(keyword, "keyword");
            Keywords index;

            if (_keywords.TryGetValue(keyword, out index))
            {
                value = GetAt(index);
                return(true);
            }
            return(base.TryGetValue(keyword, out value));
        }
예제 #7
0
        public override string UnquoteIdentifier(string quotedIdentifier)
        {
            ADP.CheckArgumentNull(quotedIdentifier, "quotedIdentifier");
            String unquotedIdentifier;
            string quoteSuffixLocal = QuoteSuffix;
            string quotePrefixLocal = QuotePrefix;

            ConsistentQuoteDelimiters(quotePrefixLocal, quoteSuffixLocal);
            // ignoring the return value becasue an unquoted source string is OK here
            ADP.RemoveStringQuotes(quotePrefixLocal, quoteSuffixLocal, quotedIdentifier, out unquotedIdentifier);
            return(unquotedIdentifier);
        }
예제 #8
0
        // Send results from SqlDataReader
        public void Send(SqlDataReader reader)
        {
            ADP.CheckArgumentNull(reader, "reader");

            SetPipeBusy( );
            try {
                EnsureNormalSendValid("Send");
                do
                {
                    SmiExtendedMetaData[] columnMetaData = reader.GetInternalSmiMetaData();

                    if (null != columnMetaData && 0 != columnMetaData.Length)   // SQLBUDT #340528 -- don't send empty results.
                    {
                        using (SmiRecordBuffer recordBuffer = _smiContext.CreateRecordBuffer(columnMetaData, _eventSink)) {
                            _eventSink.ProcessMessagesAndThrow(); // Handle any errors that are reported.


                            _smiContext.SendResultsStartToPipe(recordBuffer, _eventSink);
                            _eventSink.ProcessMessagesAndThrow(); // Handle any errors that are reported.

                            try {
                                while (reader.Read( ))
                                {
                                    if (SmiContextFactory.Instance.NegotiatedSmiVersion >= SmiContextFactory.KatmaiVersion)
                                    {
                                        ValueUtilsSmi.FillCompatibleSettersFromReader(_eventSink, recordBuffer, new List <SmiExtendedMetaData>(columnMetaData), reader);
                                    }
                                    else
                                    {
                                        ValueUtilsSmi.FillCompatibleITypedSettersFromReader(_eventSink, recordBuffer, columnMetaData, reader);
                                    }

                                    _smiContext.SendResultsRowToPipe(recordBuffer, _eventSink);
                                    _eventSink.ProcessMessagesAndThrow(); // Handle any errors that are reported.
                                }
                            }
                            finally {
                                _smiContext.SendResultsEndToPipe(recordBuffer, _eventSink);
                                _eventSink.ProcessMessagesAndThrow(); // Handle any errors that are reported.
                            }
                        }
                    }
                }while (reader.NextResult( ));
            }
            catch {
                _eventSink.CleanMessages();
                throw;
            }
            finally {
                ClearPipeBusy( );
                Debug.Assert(_eventSink.HasMessages == false, "There should be no messages left in _eventsink at the end of the Send reader!");
            }
        }
        public override string UnquoteIdentifier(string quotedIdentifier)
        {
            string str3;

            ADP.CheckArgumentNull(quotedIdentifier, "quotedIdentifier");
            string quoteSuffix = this.QuoteSuffix;
            string quotePrefix = this.QuotePrefix;

            this.ConsistentQuoteDelimiters(quotePrefix, quoteSuffix);
            ADP.RemoveStringQuotes(quotePrefix, quoteSuffix, quotedIdentifier, out str3);
            return(str3);
        }
예제 #10
0
        public void ClearPool(DbConnectionPoolKey key)
        {
            ADP.CheckArgumentNull(key.ConnectionString, nameof(key) + "." + nameof(key.ConnectionString));

            DbConnectionPoolGroup poolGroup;
            Dictionary <DbConnectionPoolKey, DbConnectionPoolGroup> connectionPoolGroups = _connectionPoolGroups;

            if (connectionPoolGroups.TryGetValue(key, out poolGroup))
            {
                poolGroup.Clear();
            }
        }
        public override bool TryGetValue(string keyword, [NotNullWhen(true)] out object?value)
        {
            ADP.CheckArgumentNull(keyword, nameof(keyword));
            Keywords index;

            if (s_keywords.TryGetValue(keyword, out index))
            {
                value = GetAt(index);
                return(true);
            }
            return(base.TryGetValue(keyword, out value));
        }
 public void ClearPool(DbConnection connection)
 {
     ADP.CheckArgumentNull(connection, nameof(connection));
     using (TryEventScope.Create("<prov.DbConnectionFactory.ClearPool|API> {0}", GetObjectId(connection)))
     {
         DbConnectionPoolGroup poolGroup = GetConnectionPoolGroup(connection);
         if (null != poolGroup)
         {
             poolGroup.Clear();
         }
     }
 }
예제 #13
0
        public override bool TryGetValue(string keyword, out object value)
        {
            Keywords keywords;

            ADP.CheckArgumentNull(keyword, "keyword");
            if (_keywords.TryGetValue(keyword, out keywords))
            {
                value = this.GetAt(keywords);
                return(true);
            }
            return(base.TryGetValue(keyword, out value));
        }
 public void ClearPool(DbConnectionPoolKey key)
 {
     Debug.Assert(key != null, "key cannot be null");
     ADP.CheckArgumentNull(key.ConnectionString, nameof(key) + "." + nameof(key.ConnectionString));
     using (TryEventScope.Create("<prov.DbConnectionFactory.ClearPool|API> connectionString"))
     {
         Dictionary <DbConnectionPoolKey, DbConnectionPoolGroup> connectionPoolGroups = _connectionPoolGroups;
         if (connectionPoolGroups.TryGetValue(key, out DbConnectionPoolGroup poolGroup))
         {
             poolGroup.Clear();
         }
     }
 }
예제 #15
0
        private OdbcParameter(OdbcParameter source) : this() // V1.2.3300, Clone
        {
            ADP.CheckArgumentNull(source, nameof(source));

            source.CloneHelper(this);

            ICloneable cloneable = (_value as ICloneable);

            if (null != cloneable)
            { // MDAC 49322
                _value = cloneable.Clone();
            }
        }
예제 #16
0
        public void ClearPool(DbConnectionPoolKey key)
        {
            Debug.Assert(key != null, "key cannot be null");
            ADP.CheckArgumentNull(key.ConnectionString, nameof(key) + "." + nameof(key.ConnectionString));

            DbConnectionPoolGroup?poolGroup;
            Dictionary <DbConnectionPoolKey, DbConnectionPoolGroup> connectionPoolGroups = _connectionPoolGroups;

            if (connectionPoolGroups.TryGetValue(key, out poolGroup))
            {
                poolGroup.Clear();
            }
        }
예제 #17
0
        private OleDbParameter(OleDbParameter source) : this()
        { // V1.2.3300, Clone
            ADP.CheckArgumentNull(source, "source");

            source.CloneHelper(this);

            ICloneable?cloneable = (_value as ICloneable);

            if (null != cloneable)
            {
                _value = cloneable.Clone();
            }
        }
예제 #18
0
        private PARAMETEROBJECTNAME(PARAMETEROBJECTNAME source) : this()   // V1.2.3300, Clone
        {
            ADP.CheckArgumentNull(source, "source");

            source.CloneHelper(this);

            ICloneable cloneable = (_value as ICloneable);

            if (null != cloneable)   // MDAC 49322
            {
                _value = cloneable.Clone();
            }
        }
예제 #19
0
        private SqlParameter(SqlParameter source) : this()
        { // V1.2.3300, Clone
            ADP.CheckArgumentNull(source, "source");

            source.CloneHelper(this);

            ICloneable cloneable = (_value as ICloneable);

            if (null != cloneable)
            { // MDAC 49322
                _value = cloneable.Clone();
            }
        }
예제 #20
0
        public void SendResultsRow(SqlDataRecord record)
        {
            ADP.CheckArgumentNull(record, "record");

            SetPipeBusy( );
            try {
                EnsureResultStarted("SendResultsRow");

                if (_hadErrorInResultSet)
                {
                    throw SQL.SqlPipeErrorRequiresSendEnd();
                }

                // Assume error state unless cleared below
                _hadErrorInResultSet = true;

                SmiRecordBuffer recordBuffer;
                if (record.RecordContext == _smiContext)
                {
                    recordBuffer = record.RecordBuffer;
                }
                else
                {
                    SmiExtendedMetaData[] columnMetaData = record.InternalGetSmiMetaData();
                    recordBuffer = _smiContext.CreateRecordBuffer(columnMetaData, _eventSink);
                    if (SmiContextFactory.Instance.NegotiatedSmiVersion >= SmiContextFactory.KatmaiVersion)
                    {
                        ValueUtilsSmi.FillCompatibleSettersFromRecord(_eventSink, recordBuffer, columnMetaData, record, null /* no default values */);
                    }
                    else
                    {
                        ValueUtilsSmi.FillCompatibleITypedSettersFromRecord(_eventSink, recordBuffer, columnMetaData, record);
                    }
                }
                _smiContext.SendResultsRowToPipe(recordBuffer, _eventSink);

                // Handle any errors that are reported.
                _eventSink.ProcessMessagesAndThrow();

                // We successfully traversed the send, clear error state
                _hadErrorInResultSet = false;
            }
            catch {
                _eventSink.CleanMessages();
                throw;
            }
            finally {
                ClearPipeBusy( );
                Debug.Assert(_eventSink.HasMessages == false, "There should be no messages left in _eventsink at the end of the SendResultsRow!");
            }
        }
예제 #21
0
 public static void ClearPool(SqlConnection connection)
 {
     ADP.CheckArgumentNull(connection, "connection");
     DbConnectionOptions userConnectionOptions = connection.UserConnectionOptions;
     if (userConnectionOptions != null)
     {
         userConnectionOptions.DemandPermission();
         if (connection.IsContextConnection)
         {
             throw SQL.NotAvailableOnContextConnection();
         }
         SqlConnectionFactory.SingletonInstance.ClearPool(connection);
     }
 }
예제 #22
0
        internal void CopyTo(SqlParameter destination)
        {
            ADP.CheckArgumentNull(destination, nameof(destination));

            // NOTE: _parent is not cloned
            destination._value                   = _value;
            destination._direction               = _direction;
            destination._size                    = _size;
            destination._offset                  = _offset;
            destination._sourceColumn            = _sourceColumn;
            destination._sourceVersion           = _sourceVersion;
            destination._sourceColumnNullMapping = _sourceColumnNullMapping;
            destination._isNullable              = _isNullable;
        }
예제 #23
0
        public DbMetaDataFactory(Stream xmlStream, string serverVersion, string normalizedServerVersion)
        {
            ADP.CheckArgumentNull(xmlStream, "xmlStream");
            ADP.CheckArgumentNull(serverVersion, "serverVersion");
            ADP.CheckArgumentNull(normalizedServerVersion, "normalizedServerVersion");

            _metaDataCollectionsDataSet = new DataSet {
                Locale = CultureInfo.InvariantCulture
            };
            _metaDataCollectionsDataSet.ReadXml(xmlStream);

            _serverVersionString     = serverVersion;
            _normalizedServerVersion = normalizedServerVersion;
        }
예제 #24
0
 private void CopyFrom(OdbcConnection connection)
 {
     ADP.CheckArgumentNull(connection, "connection");
     this._userConnectionOptions = connection.UserConnectionOptions;
     this._poolGroup             = connection.PoolGroup;
     if (DbConnectionClosedNeverOpened.SingletonInstance == connection._innerConnection)
     {
         this._innerConnection = DbConnectionClosedNeverOpened.SingletonInstance;
     }
     else
     {
         this._innerConnection = DbConnectionClosedPreviouslyOpened.SingletonInstance;
     }
 }
        public override bool Remove(string keyword)
        {
            ADP.CheckArgumentNull(keyword, nameof(keyword));
            Keywords index;

            if (s_keywords.TryGetValue(keyword, out index))
            {
                if (base.Remove(s_validKeywords[(int)index]))
                {
                    Reset(index);
                    return(true);
                }
            }
            return(false);
        }
예제 #26
0
        private void CopyFrom(SqlConnection connection)
        {
            ADP.CheckArgumentNull(connection, nameof(connection));
            _userConnectionOptions = connection.UserConnectionOptions;
            _poolGroup             = connection.PoolGroup;

            if (DbConnectionClosedNeverOpened.SingletonInstance == connection._innerConnection)
            {
                _innerConnection = DbConnectionClosedNeverOpened.SingletonInstance;
            }
            else
            {
                _innerConnection = DbConnectionClosedPreviouslyOpened.SingletonInstance;
            }
        }
        public override object this[string keyword]
        {
            get
            {
                ADP.CheckArgumentNull(keyword, "keyword");
                Keywords index;
                if (s_keywords.TryGetValue(keyword, out index))
                {
                    return(GetAt(index));
                }
                else
                {
                    return(base[keyword]);
                }
            }
            set
            {
                ADP.CheckArgumentNull(keyword, "keyword");
                if (null != value)
                {
                    Keywords index;
                    if (s_keywords.TryGetValue(keyword, out index))
                    {
                        switch (index)
                        {
                        case Keywords.Driver: Driver = ConvertToString(value); break;

                        case Keywords.Dsn: Dsn = ConvertToString(value); break;

                        //                      case Keywords.NamedConnection: NamedConnection = ConvertToString(value); break;
                        default:
                            Debug.Assert(false, "unexpected keyword");
                            throw ADP.KeywordNotSupported(keyword);
                        }
                    }
                    else
                    {
                        base[keyword] = value;
                        ClearPropertyDescriptors();
                        _knownKeywords = null;
                    }
                }
                else
                {
                    Remove(keyword);
                }
            }
        }
예제 #28
0
 public void Send(SqlDataReader reader)
 {
     ADP.CheckArgumentNull(reader, "reader");
     this.SetPipeBusy();
     try
     {
         this.EnsureNormalSendValid("Send");
         do
         {
             SmiExtendedMetaData[] internalSmiMetaData = reader.GetInternalSmiMetaData();
             if ((internalSmiMetaData != null) && (internalSmiMetaData.Length != 0))
             {
                 using (SmiRecordBuffer buffer = this._smiContext.CreateRecordBuffer(internalSmiMetaData, this._eventSink))
                 {
                     this._eventSink.ProcessMessagesAndThrow();
                     this._smiContext.SendResultsStartToPipe(buffer, this._eventSink);
                     this._eventSink.ProcessMessagesAndThrow();
                     try
                     {
                         while (reader.Read())
                         {
                             if (SmiContextFactory.Instance.NegotiatedSmiVersion >= 210L)
                             {
                                 ValueUtilsSmi.FillCompatibleSettersFromReader(this._eventSink, buffer, new List <SmiExtendedMetaData>(internalSmiMetaData), reader);
                             }
                             else
                             {
                                 ValueUtilsSmi.FillCompatibleITypedSettersFromReader(this._eventSink, buffer, internalSmiMetaData, reader);
                             }
                             this._smiContext.SendResultsRowToPipe(buffer, this._eventSink);
                             this._eventSink.ProcessMessagesAndThrow();
                         }
                     }
                     finally
                     {
                         this._smiContext.SendResultsEndToPipe(buffer, this._eventSink);
                         this._eventSink.ProcessMessagesAndThrow();
                     }
                 }
             }
         }while (reader.NextResult());
     }
     finally
     {
         this.ClearPipeBusy();
     }
 }
예제 #29
0
        public override bool Remove(string keyword)
        {
            ADP.CheckArgumentNull(keyword, "keyword");
            bool value = base.Remove(keyword);

            Keywords index;

            if (s_keywords.TryGetValue(keyword, out index))
            {
                Reset(index);
            }
            else if (value)
            {
                ClearPropertyDescriptors();
            }
            return(value);
        }
예제 #30
0
        // Copy Constructor
        private void CopyFrom(OleDbConnection connection)
        { // V1.2.3300
            ADP.CheckArgumentNull(connection, "connection");
            _userConnectionOptions = connection.UserConnectionOptions;
            _poolGroup             = connection.PoolGroup;

            //  Match the original connection's behavior for whether the connection was never opened,
            //  but ensure Clone is in the closed state.
            if (DbConnectionClosedNeverOpened.SingletonInstance == connection._innerConnection)
            {
                _innerConnection = DbConnectionClosedNeverOpened.SingletonInstance;
            }
            else
            {
                _innerConnection = DbConnectionClosedPreviouslyOpened.SingletonInstance;
            }
        }