Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / HttpTransportManager.cs / 1 / HttpTransportManager.cs
//---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------------------- namespace System.ServiceModel.Channels { using System.Collections.Generic; using System.ServiceModel; abstract class HttpTransportManager : TransportManager, ITransportManagerRegistration { Dictionary> addressTables; HostNameComparisonMode hostNameComparisonMode; Uri listenUri; string realm; internal HttpTransportManager() { this.addressTables = new Dictionary >(); } internal HttpTransportManager(Uri listenUri, HostNameComparisonMode hostNameComparisonMode, string realm) : this() { this.hostNameComparisonMode = hostNameComparisonMode; this.listenUri = listenUri; this.realm = realm; } internal string Realm { get { return this.realm; } } public HostNameComparisonMode HostNameComparisonMode { get { return this.hostNameComparisonMode; } protected set { // used by HostedHttpTransportManager lock (base.ThisLock) { ThrowIfOpen(); this.hostNameComparisonMode = value; } } } internal override string Scheme { get { return Uri.UriSchemeHttp; } } internal virtual UriPrefixTable TransportManagerTable { get { return HttpChannelListener.StaticTransportManagerTable; } } public Uri ListenUri { get { return this.listenUri; } protected set { this.listenUri = value; } } protected void Fault(Exception exception) { lock (ThisLock) { foreach (KeyValuePair > pair in this.addressTables) { this.Fault(pair.Value, exception); } } } internal virtual bool IsCompatible(HttpChannelListener listener) { return ( (this.hostNameComparisonMode == listener.HostNameComparisonMode) && (this.realm == listener.Realm) ); } internal override void OnClose() { this.TransportManagerTable.UnregisterUri(this.ListenUri, this.HostNameComparisonMode); } protected bool TryLookupUri(Uri requestUri, string requestMethod, HostNameComparisonMode hostNameComparisonMode, out HttpChannelListener listener) { listener = null; if (requestMethod == null) { requestMethod = string.Empty; } lock (addressTables) { UriPrefixTable addressTable; // check for a method match if necessary HttpChannelListener methodListener = null; if (requestMethod.Length > 0) { if (addressTables.TryGetValue(requestMethod, out addressTable)) { if (addressTable.TryLookupUri(requestUri, hostNameComparisonMode, out methodListener) && string.Compare(requestUri.AbsolutePath, methodListener.Uri.AbsolutePath, StringComparison.OrdinalIgnoreCase) != 0) { methodListener = null; } } } // and also check the wildcard bucket if (addressTables.TryGetValue(string.Empty, out addressTable) && addressTable.TryLookupUri(requestUri, hostNameComparisonMode, out listener)) { if (methodListener != null && methodListener.Uri.AbsoluteUri.Length >= listener.Uri.AbsoluteUri.Length) { listener = methodListener; } } else { listener = methodListener; } } return (listener != null); } internal override void Register(TransportChannelListener channelListener) { UriPrefixTable addressTable; lock (addressTables) { string method = ((HttpChannelListener)channelListener).Method; if (!addressTables.TryGetValue(method, out addressTable)) { addressTable = new UriPrefixTable (); addressTables[method] = addressTable; } } addressTable.RegisterUri(channelListener.Uri, channelListener.InheritBaseAddressSettings ? hostNameComparisonMode : channelListener.HostNameComparisonModeInternal, (HttpChannelListener)channelListener); } IList ITransportManagerRegistration.Select(TransportChannelListener channelListener) { IList result = null; if (this.IsCompatible((HttpChannelListener)channelListener)) { result = new List (); result.Add(this); } return result; } internal override void Unregister(TransportChannelListener channelListener) { UriPrefixTable addressTable; lock (addressTables) { string method = ((HttpChannelListener)channelListener).Method; if (!addressTables.TryGetValue(method, out addressTable)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString( SR.ListenerFactoryNotRegistered, channelListener.Uri))); } } HostNameComparisonMode registeredMode = channelListener.InheritBaseAddressSettings ? hostNameComparisonMode : channelListener.HostNameComparisonModeInternal; EnsureRegistered(addressTable, (HttpChannelListener)channelListener, registeredMode); addressTable.UnregisterUri(channelListener.Uri, registeredMode); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebPartHeaderCloseVerb.cs
- XmlSchemaGroupRef.cs
- SecUtil.cs
- LocalizedNameDescriptionPair.cs
- ButtonBase.cs
- DataBinder.cs
- BufferedGraphicsContext.cs
- Polygon.cs
- GetPolicyDetailsRequest.cs
- InputScopeNameConverter.cs
- MethodAccessException.cs
- InstanceKeyNotReadyException.cs
- LoginCancelEventArgs.cs
- PriorityChain.cs
- AsyncStreamReader.cs
- webeventbuffer.cs
- IdentityReference.cs
- TimeZone.cs
- WebPermission.cs
- Brush.cs
- GlyphCollection.cs
- XsdCachingReader.cs
- DocumentScope.cs
- AspNetPartialTrustHelpers.cs
- TraceRecord.cs
- WindowsFormsSynchronizationContext.cs
- SafeArrayTypeMismatchException.cs
- PeerNameRegistration.cs
- GridViewRowPresenter.cs
- SchemaNames.cs
- NameValueSectionHandler.cs
- CircleHotSpot.cs
- PermissionSet.cs
- TextContainer.cs
- PackagePartCollection.cs
- TimeSpanConverter.cs
- SmiSettersStream.cs
- RawStylusInputCustomData.cs
- ToolStripSeparator.cs
- TypeUtil.cs
- GeneralTransform3DTo2DTo3D.cs
- SafeRightsManagementHandle.cs
- ActivitySurrogate.cs
- TreeNodeSelectionProcessor.cs
- DiscardableAttribute.cs
- XmlDataSourceView.cs
- GridViewCancelEditEventArgs.cs
- FastEncoder.cs
- StrokeIntersection.cs
- AttachInfo.cs
- DbParameterCollection.cs
- ScrollItemPattern.cs
- ADMembershipProvider.cs
- SystemFonts.cs
- SubqueryRules.cs
- SendSecurityHeader.cs
- WhitespaceSignificantCollectionAttribute.cs
- DataTableMappingCollection.cs
- HandleCollector.cs
- WpfGeneratedKnownProperties.cs
- GridLength.cs
- ExtensionQuery.cs
- Bezier.cs
- BinaryParser.cs
- MetadataHelper.cs
- LinkedResourceCollection.cs
- CalendarBlackoutDatesCollection.cs
- AnchorEditor.cs
- TransformedBitmap.cs
- TypefaceMetricsCache.cs
- CatalogPart.cs
- NativeRightsManagementAPIsStructures.cs
- ContextMarshalException.cs
- BaseValidatorDesigner.cs
- PrintDialog.cs
- QueryableDataSourceHelper.cs
- SynchronousChannelMergeEnumerator.cs
- Deflater.cs
- UIElementHelper.cs
- CompositeTypefaceMetrics.cs
- MailWebEventProvider.cs
- HttpCapabilitiesBase.cs
- RootBrowserWindowProxy.cs
- PageTheme.cs
- XmlReflectionMember.cs
- TextTrailingWordEllipsis.cs
- OracleTransaction.cs
- RelatedImageListAttribute.cs
- SmiMetaData.cs
- DescendantQuery.cs
- PEFileReader.cs
- XmlSchemaAnyAttribute.cs
- MailWebEventProvider.cs
- WeakRefEnumerator.cs
- SharedConnectionInfo.cs
- Geometry3D.cs
- TargetParameterCountException.cs
- mediaeventshelper.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- CodeMemberEvent.cs