Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / SqlClient / SqlConnectionPoolGroupProviderInfo.cs / 1305376 / SqlConnectionPoolGroupProviderInfo.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data.SqlClient { using System; using System.Data; using System.Data.Common; using System.Data.ProviderBase; sealed internal class SqlConnectionPoolGroupProviderInfo : DbConnectionPoolGroupProviderInfo { private string _alias; private System.Security.PermissionSet _failoverPermissionSet; private string _failoverPartner; private bool _useFailoverPartner; internal SqlConnectionPoolGroupProviderInfo(SqlConnectionString connectionOptions) { // This is for the case where the user specified the failover partner // in the connection string and we have not yet connected to get the // env change. _failoverPartner = connectionOptions.FailoverPartner; if (ADP.IsEmpty(_failoverPartner)) { _failoverPartner = null; } } internal string FailoverPartner { get { return _failoverPartner; } } internal bool UseFailoverPartner { get { return _useFailoverPartner; } } internal void AliasCheck(string server) { if (_alias != server) { lock(this) { if (null == _alias) { _alias = server; } else if (_alias != server) { Bid.Trace("alias change detected. Clearing PoolGroup\n"); base.PoolGroup.Clear(); _alias = server; } } } } private System.Security.PermissionSet CreateFailoverPermission(SqlConnectionString userConnectionOptions, string actualFailoverPartner) { string keywordToReplace; // RULES FOR CONSTRUCTING THE CONNECTION STRING TO DEMAND ON: // // 1) If no Failover Partner was specified in the original string: // // Server=actualFailoverPartner // // 2) If Failover Partner was specified in the original string: // // Server=originalValue; Failover Partner=actualFailoverPartner // // NOTE: in all cases, when we get a failover partner name from // the server, we will use that name over what was specified // in the original connection string. if (null == userConnectionOptions[SqlConnectionString.KEY.FailoverPartner]) { keywordToReplace = SqlConnectionString.KEY.Data_Source; } else { keywordToReplace = SqlConnectionString.KEY.FailoverPartner; } string failoverConnectionString = userConnectionOptions.ExpandKeyword(keywordToReplace, actualFailoverPartner); return (new SqlConnectionString(failoverConnectionString)).CreatePermissionSet(); } internal void FailoverCheck(SqlInternalConnection connection, bool actualUseFailoverPartner, SqlConnectionString userConnectionOptions, string actualFailoverPartner) { if (UseFailoverPartner != actualUseFailoverPartner) { // Bid.Trace(" Failover detected. failover partner='%ls'. Clearing PoolGroup\n", actualFailoverPartner); base.PoolGroup.Clear(); _useFailoverPartner = actualUseFailoverPartner; } // Only construct a new permission set when we're connecting to the // primary data source, not the failover partner. if (!_useFailoverPartner && _failoverPartner != actualFailoverPartner) { // NOTE: we optimisitically generate the permission set to keep // lock short, but we only do this when we get a new // failover partner. // System.Security.PermissionSet failoverPermissionSet = CreateFailoverPermission(userConnectionOptions, actualFailoverPartner); lock (this) { if (_failoverPartner != actualFailoverPartner) { _failoverPartner = actualFailoverPartner; _failoverPermissionSet = failoverPermissionSet; } } } } internal void FailoverPermissionDemand() { if (_useFailoverPartner) { // Note that we only demand when there is a permission set, which only // happens once we've identified a failover situation in FailoverCheck System.Security.PermissionSet failoverPermissionSet = _failoverPermissionSet; if (null != failoverPermissionSet) { // demand on pooled failover connections failoverPermissionSet.Demand(); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DispatcherSynchronizationContext.cs
- AnimatedTypeHelpers.cs
- XmlTextAttribute.cs
- ActivityContext.cs
- DelegatingConfigHost.cs
- CharacterMetrics.cs
- filewebresponse.cs
- ModelVisual3D.cs
- ProfileGroupSettingsCollection.cs
- SearchForVirtualItemEventArgs.cs
- PeerNearMe.cs
- QilIterator.cs
- StrongNamePublicKeyBlob.cs
- Schedule.cs
- OneOf.cs
- DocumentSequenceHighlightLayer.cs
- MainMenu.cs
- ConstantExpression.cs
- CodeGeneratorOptions.cs
- EUCJPEncoding.cs
- SafeEventLogWriteHandle.cs
- BulletDecorator.cs
- Style.cs
- ZipPackagePart.cs
- autovalidator.cs
- _WebProxyDataBuilder.cs
- WebServiceHandler.cs
- Helpers.cs
- DesignTimeTemplateParser.cs
- MarginsConverter.cs
- RangeValueProviderWrapper.cs
- SqlWebEventProvider.cs
- InvokeSchedule.cs
- SchemaMerger.cs
- NullableConverter.cs
- SqlVersion.cs
- HttpApplication.cs
- TextTreeUndo.cs
- EmptyEnumerable.cs
- DataBoundControlHelper.cs
- ToolboxComponentsCreatedEventArgs.cs
- WebEventCodes.cs
- DataColumnMappingCollection.cs
- ListBindingHelper.cs
- WebBrowsableAttribute.cs
- SqlUtil.cs
- CellQuery.cs
- PrintDocument.cs
- OrderPreservingMergeHelper.cs
- BamlTreeUpdater.cs
- LogSwitch.cs
- UInt64.cs
- WindowHideOrCloseTracker.cs
- NamespaceInfo.cs
- SchemaImporterExtension.cs
- XmlSchema.cs
- LicenseManager.cs
- HtmlHistory.cs
- PropertyKey.cs
- SyndicationDeserializer.cs
- CodeIdentifier.cs
- DetailsViewInsertEventArgs.cs
- X509SecurityTokenParameters.cs
- CodeConditionStatement.cs
- CodeDomComponentSerializationService.cs
- XmlWriter.cs
- AgileSafeNativeMemoryHandle.cs
- Propagator.cs
- SslStream.cs
- MembershipPasswordException.cs
- Directory.cs
- CodeTypeConstructor.cs
- ErrorEventArgs.cs
- MachineKeySection.cs
- ProviderConnectionPoint.cs
- DoubleMinMaxAggregationOperator.cs
- ValidatorCompatibilityHelper.cs
- VarRefManager.cs
- unitconverter.cs
- TrustManager.cs
- MessageDescriptionCollection.cs
- HandoffBehavior.cs
- GridViewColumnCollectionChangedEventArgs.cs
- XPathPatternBuilder.cs
- HierarchicalDataBoundControl.cs
- IncrementalCompileAnalyzer.cs
- InvalidComObjectException.cs
- TrackingExtract.cs
- DirectionalLight.cs
- ResponseStream.cs
- OutOfMemoryException.cs
- AppSettingsExpressionBuilder.cs
- EventProxy.cs
- MSAAWinEventWrap.cs
- XmlSchemaComplexContent.cs
- ObjectListShowCommandsEventArgs.cs
- OracleParameterCollection.cs
- SafeNativeHandle.cs
- XmlWriter.cs
- HMACSHA384.cs