本文整理汇总了C#中System.Data.Common.DbConnectionOptions类的典型用法代码示例。如果您正苦于以下问题:C# DbConnectionOptions类的具体用法?C# DbConnectionOptions怎么用?C# DbConnectionOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbConnectionOptions类属于System.Data.Common命名空间,在下文中一共展示了DbConnectionOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DbConnectionPoolGroup
internal DbConnectionPoolGroup(System.Data.Common.DbConnectionOptions connectionOptions, System.Data.ProviderBase.DbConnectionPoolGroupOptions poolGroupOptions)
{
this._connectionOptions = connectionOptions;
this._poolGroupOptions = poolGroupOptions;
this._poolCollection = new HybridDictionary(1, false);
this._state = 1;
}
示例2: DbConnectionPoolGroup
internal DbConnectionPoolGroup(DbConnectionOptions connectionOptions, DbConnectionPoolGroupOptions poolGroupOptions)
{
this._connectionOptions = connectionOptions;
this._poolGroupOptions = poolGroupOptions;
this._poolCollection = new HybridDictionary(1, false);
this._state = 1;
}
示例3: DbConnectionOptions
protected DbConnectionOptions(DbConnectionOptions connectionOptions)
{
this._usersConnectionString = connectionOptions._usersConnectionString;
this.HasPasswordKeyword = connectionOptions.HasPasswordKeyword;
this.UseOdbcRules = connectionOptions.UseOdbcRules;
this._parsetable = connectionOptions._parsetable;
this.KeyChain = connectionOptions.KeyChain;
}
示例4: DBDataPermission
internal DBDataPermission(DbConnectionOptions connectionOptions)
{
this._keyvaluetree = NameValuePermission.Default;
if (connectionOptions != null)
{
this._allowBlankPassword = connectionOptions.HasBlankPassword;
this.AddPermissionEntry(new DBConnectionString(connectionOptions));
}
}
示例5: DBConnectionString
private DBConnectionString(DbConnectionOptions connectionOptions, string restrictions, KeyRestrictionBehavior behavior, Hashtable synonyms, bool mustCloneDictionary)
{
Debug.Assert(null != connectionOptions, "null connectionOptions");
switch (behavior)
{
case KeyRestrictionBehavior.PreventUsage:
case KeyRestrictionBehavior.AllowOnly:
_behavior = behavior;
break;
default:
throw ADP.InvalidKeyRestrictionBehavior(behavior);
}
// grab all the parsed details from DbConnectionOptions
_encryptedUsersConnectionString = connectionOptions.UsersConnectionString(false);
_hasPassword = connectionOptions._hasPasswordKeyword;
_parsetable = connectionOptions.Parsetable;
_keychain = connectionOptions._keyChain;
// we do not want to serialize out user password unless directed so by "persist security info=true"
// otherwise all instances of user's password will be replaced with "*"
if (_hasPassword && !connectionOptions.HasPersistablePassword)
{
if (mustCloneDictionary)
{
// clone the hashtable to replace user's password/pwd value with "*"
// we only need to clone if coming from DbConnectionOptions and password exists
_parsetable = (Hashtable)_parsetable.Clone();
}
// different than Everett in that instead of removing password/pwd from
// the hashtable, we replace the value with '*'. This is okay since we
// serialize out with '*' so already knows what we do. Better this way
// than to treat password specially later on which causes problems.
const string star = "*";
if (_parsetable.ContainsKey(KEY.Password))
{
_parsetable[KEY.Password] = star;
}
if (_parsetable.ContainsKey(KEY.Pwd))
{
_parsetable[KEY.Pwd] = star;
}
// replace user's password/pwd value with "*" in the linked list and build a new string
_keychain = connectionOptions.ReplacePasswordPwd(out _encryptedUsersConnectionString, true);
}
if (!string.IsNullOrEmpty(restrictions))
{
_restrictionValues = ParseRestrictions(restrictions, synonyms);
_restrictions = restrictions;
}
}
示例6: DbConnectionPoolGroup
private const int PoolGroupStateDisabled = 4; // factory pool entry prunning method
internal DbConnectionPoolGroup (DbConnectionOptions connectionOptions, DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolGroupOptions) {
Debug.Assert(null != connectionOptions, "null connection options");
Debug.Assert(null == poolGroupOptions || ADP.IsWindowsNT, "should not have pooling options on Win9x");
_connectionOptions = connectionOptions;
_poolKey = key;
_poolGroupOptions = poolGroupOptions;
// always lock this object before changing state
// HybridDictionary does not create any sub-objects until add
// so it is safe to use for non-pooled connection as long as
// we check _poolGroupOptions first
_poolCollection = new ConcurrentDictionary<DbConnectionPoolIdentity, DbConnectionPool>();
_state = PoolGroupStateActive; // VSWhidbey 112102
}
示例7: ConnectionString_Set
private void ConnectionString_Set(DbConnectionPoolKey key)
{
DbConnectionOptions connectionOptions = null;
System.Data.ProviderBase.DbConnectionPoolGroup poolGroup = ConnectionFactory.GetConnectionPoolGroup(key, null, ref connectionOptions);
DbConnectionInternal connectionInternal = InnerConnection;
bool flag = connectionInternal.AllowSetConnectionString;
if (flag)
{
flag = SetInnerConnectionFrom(DbConnectionClosedBusy.SingletonInstance, connectionInternal);
if (flag)
{
_userConnectionOptions = connectionOptions;
_poolGroup = poolGroup;
_innerConnection = DbConnectionClosedNeverOpened.SingletonInstance;
}
}
if (!flag)
{
throw ADP.OpenConnectionPropertySet(ADP.ConnectionString, connectionInternal.State);
}
}
示例8: SetConnectionString
protected void SetConnectionString (DbConnectionOptions constr)
{
throw new NotImplementedException ();
}
示例9: CreateConnection
override protected DbConnectionInternal CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) {
return CreateConnection(options, poolKey, poolGroupProviderInfo, pool, owningConnection, userOptions: null);
}
示例10: CreateConnectionPoolGroupOptions
override protected DbConnectionPoolGroupOptions CreateConnectionPoolGroupOptions( DbConnectionOptions connectionOptions ) {
SqlConnectionString opt = (SqlConnectionString)connectionOptions;
DbConnectionPoolGroupOptions poolingOptions = null;
if (!opt.ContextConnection && opt.Pooling) { // never pool context connections.
int connectionTimeout = opt.ConnectTimeout;
if ((0 < connectionTimeout) && (connectionTimeout < Int32.MaxValue/1000))
connectionTimeout *= 1000;
else if (connectionTimeout >= Int32.MaxValue/1000)
connectionTimeout = Int32.MaxValue;
poolingOptions = new DbConnectionPoolGroupOptions(
opt.IntegratedSecurity,
opt.MinPoolSize,
opt.MaxPoolSize,
connectionTimeout,
opt.LoadBalanceTimeout,
opt.Enlist);
}
return poolingOptions;
}
示例11: CreateConnectionOptions
protected override DbConnectionOptions CreateConnectionOptions(string connectionString, DbConnectionOptions previous) {
Debug.Assert(!ADP.IsEmpty(connectionString), "empty connectionString");
SqlConnectionString result = new SqlConnectionString(connectionString);
return result;
}
示例12: TryGetConnection
private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObjectsTimeout, bool allowCreate, bool onlyOneCheckConnection, DbConnectionOptions userOptions, out DbConnectionInternal connection)
{
DbConnectionInternal obj = null;
if (null == obj)
{
Interlocked.Increment(ref _waitCount);
do
{
int waitResult = BOGUS_HANDLE;
try
{
try
{
}
finally
{
waitResult = WaitHandle.WaitAny(_waitHandles.GetHandles(allowCreate), unchecked((int)waitForMultipleObjectsTimeout));
}
// From the WaitAny docs: "If more than one object became signaled during
// the call, this is the array index of the signaled object with the
// smallest index value of all the signaled objects." This is important
// so that the free object signal will be returned before a creation
// signal.
switch (waitResult)
{
case WaitHandle.WaitTimeout:
Interlocked.Decrement(ref _waitCount);
connection = null;
return false;
case ERROR_HANDLE:
// Throw the error that PoolCreateRequest stashed.
Interlocked.Decrement(ref _waitCount);
throw TryCloneCachedException();
case CREATION_HANDLE:
try
{
obj = UserCreateRequest(owningObject, userOptions);
}
catch
{
if (null == obj)
{
Interlocked.Decrement(ref _waitCount);
}
throw;
}
finally
{
// Ensure that we release this waiter, regardless
// of any exceptions that may be thrown.
if (null != obj)
{
Interlocked.Decrement(ref _waitCount);
}
}
if (null == obj)
{
// If we were not able to create an object, check to see if
// we reached MaxPoolSize. If so, we will no longer wait on
// the CreationHandle, but instead wait for a free object or
// the timeout.
if (Count >= MaxPoolSize && 0 != MaxPoolSize)
{
if (!ReclaimEmancipatedObjects())
{
// modify handle array not to wait on creation mutex anymore
Debug.Assert(2 == CREATION_HANDLE, "creation handle changed value");
allowCreate = false;
}
}
}
break;
case SEMAPHORE_HANDLE:
//
// guaranteed available inventory
//
Interlocked.Decrement(ref _waitCount);
obj = GetFromGeneralPool();
if ((obj != null) && (!obj.IsConnectionAlive()))
{
DestroyObject(obj);
obj = null; // Setting to null in case creating a new object fails
if (onlyOneCheckConnection)
{
if (_waitHandles.CreationSemaphore.WaitOne(unchecked((int)waitForMultipleObjectsTimeout)))
{
try
{
obj = UserCreateRequest(owningObject, userOptions);
}
//.........这里部分代码省略.........
示例13: CreateObject
private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
{
DbConnectionInternal newObj = null;
try
{
newObj = _connectionFactory.CreatePooledConnection(this, owningObject, _connectionPoolGroup.ConnectionOptions, _connectionPoolGroup.PoolKey, userOptions);
if (null == newObj)
{
throw ADP.InternalError(ADP.InternalErrorCode.CreateObjectReturnedNull); // CreateObject succeeded, but null object
}
if (!newObj.CanBePooled)
{
throw ADP.InternalError(ADP.InternalErrorCode.NewObjectCannotBePooled); // CreateObject succeeded, but non-poolable object
}
newObj.PrePush(null);
lock (_objectList)
{
if ((oldConnection != null) && (oldConnection.Pool == this))
{
_objectList.Remove(oldConnection);
}
_objectList.Add(newObj);
_totalObjects = _objectList.Count;
}
// If the old connection belonged to another pool, we need to remove it from that
if (oldConnection != null)
{
var oldConnectionPool = oldConnection.Pool;
if (oldConnectionPool != null && oldConnectionPool != this)
{
Debug.Assert(oldConnectionPool._state == State.ShuttingDown, "Old connections pool should be shutting down");
lock (oldConnectionPool._objectList)
{
oldConnectionPool._objectList.Remove(oldConnection);
oldConnectionPool._totalObjects = oldConnectionPool._objectList.Count;
}
}
}
// Reset the error wait:
_errorWait = ERROR_WAIT_DEFAULT;
}
catch (Exception e)
{
if (!ADP.IsCatchableExceptionType(e))
{
throw;
}
newObj = null; // set to null, so we do not return bad new object
// Failed to create instance
_resError = e;
// Make sure the timer starts even if ThreadAbort occurs after setting the ErrorEvent.
// timer allocation has to be done out of CER block
Timer t = new Timer(new TimerCallback(this.ErrorCallback), null, Timeout.Infinite, Timeout.Infinite);
bool timerIsNotDisposed;
try { }
finally
{
_waitHandles.ErrorEvent.Set();
_errorOccurred = true;
// Enable the timer.
// Note that the timer is created to allow periodic invocation. If ThreadAbort occurs in the middle of ErrorCallback,
// the timer will restart. Otherwise, the timer callback (ErrorCallback) destroys the timer after resetting the error to avoid second callback.
_errorTimer = t;
timerIsNotDisposed = t.Change(_errorWait, _errorWait);
}
Debug.Assert(timerIsNotDisposed, "ErrorCallback timer has been disposed");
if (30000 < _errorWait)
{
_errorWait = 60000;
}
else
{
_errorWait *= 2;
}
throw;
}
return newObj;
}
示例14: UserCreateRequest
private DbConnectionInternal UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection = null)
{
// called by user when they were not able to obtain a free object but
// instead obtained creation mutex
DbConnectionInternal obj = null;
if (ErrorOccurred)
{
throw TryCloneCachedException();
}
else
{
if ((oldConnection != null) || (Count < MaxPoolSize) || (0 == MaxPoolSize))
{
// If we have an odd number of total objects, reclaim any dead objects.
// If we did not find any objects to reclaim, create a new one.
if ((oldConnection != null) || (Count & 0x1) == 0x1 || !ReclaimEmancipatedObjects())
obj = CreateObject(owningObject, userOptions, oldConnection);
}
return obj;
}
}
示例15: PendingGetConnection
public PendingGetConnection(long dueTime, DbConnection owner, TaskCompletionSource<DbConnectionInternal> completion, DbConnectionOptions userOptions)
{
DueTime = dueTime;
Owner = owner;
Completion = completion;
}