Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Dispatcher / prefixendpointaddressmessagefiltertable.cs / 1 / prefixendpointaddressmessagefiltertable.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Dispatcher
{
using System;
using System.ServiceModel.Channels;
using System.ServiceModel;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.ServiceModel.Security;
using System.Xml;
using QName = System.ServiceModel.Dispatcher.EndpointAddressProcessor.QName;
using HeaderBit = System.ServiceModel.Dispatcher.EndpointAddressProcessor.HeaderBit;
using System.ServiceModel.Diagnostics;
internal class PrefixEndpointAddressMessageFilterTable : EndpointAddressMessageFilterTable
{
UriPrefixTable toHostTable;
UriPrefixTable toNoHostTable;
public PrefixEndpointAddressMessageFilterTable() : base()
{
}
protected override void InitializeLookupTables()
{
this.toHostTable = new UriPrefixTable();
this.toNoHostTable = new UriPrefixTable();
}
public override void Add(MessageFilter filter, TFilterData data)
{
if (filter == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("filter");
}
Add((PrefixEndpointAddressMessageFilter)filter, data);
}
public override void Add(EndpointAddressMessageFilter filter, TFilterData data)
{
if (filter == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("filter");
}
DiagnosticUtility.DebugAssert("EndpointAddressMessageFilter cannot be added to PrefixEndpointAddressMessageFilterTable");
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException("EndpointAddressMessageFilter cannot be added to PrefixEndpointAddressMessageFilterTable"));
}
public void Add(PrefixEndpointAddressMessageFilter filter, TFilterData data)
{
if (filter == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("filter");
}
this.filters.Add(filter, data);
// Create the candidate
byte[] mask = BuildMask(filter.HeaderLookup);
Candidate can = new Candidate(filter, data, mask, filter.HeaderLookup);
this.candidates.Add(filter, can);
#pragma warning suppress 56506 // [....], PrefixEndpointAddressMessageFilter.Address can never be null
Uri soapToAddress = filter.Address.Uri;
CandidateSet cset;
if (!TryMatchCandidateSet(soapToAddress, filter.IncludeHostNameInComparison, out cset))
{
cset = new CandidateSet();
GetAddressTable(filter.IncludeHostNameInComparison).RegisterUri(soapToAddress, GetComparisonMode(filter.IncludeHostNameInComparison), cset);
}
cset.candidates.Add(can);
IncrementQNameCount(cset, filter.Address);
}
HostNameComparisonMode GetComparisonMode(bool includeHostNameInComparison)
{
return includeHostNameInComparison ? HostNameComparisonMode.Exact : HostNameComparisonMode.StrongWildcard;
}
UriPrefixTable GetAddressTable(bool includeHostNameInComparison)
{
return includeHostNameInComparison ? this.toHostTable : this.toNoHostTable;
}
internal override bool TryMatchCandidateSet(Uri to, bool includeHostNameInComparison, out CandidateSet cset)
{
return GetAddressTable(includeHostNameInComparison).TryLookupUri(to, GetComparisonMode(includeHostNameInComparison), out cset);
}
protected override void ClearLookupTables()
{
this.toHostTable = new UriPrefixTable.CandidateSet>();
this.toNoHostTable = new UriPrefixTable.CandidateSet>();
}
public override bool Remove(MessageFilter filter)
{
if (filter == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("filter");
}
PrefixEndpointAddressMessageFilter pFilter = filter as PrefixEndpointAddressMessageFilter;
if (pFilter != null)
{
return Remove(pFilter);
}
return false;
}
public override bool Remove(EndpointAddressMessageFilter filter)
{
if (filter == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("filter");
}
DiagnosticUtility.DebugAssert("EndpointAddressMessageFilter cannot be removed from PrefixEndpointAddressMessageFilterTable");
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException("EndpointAddressMessageFilter cannot be removed from PrefixEndpointAddressMessageFilterTable"));
}
public bool Remove(PrefixEndpointAddressMessageFilter filter)
{
if (filter == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("filter");
}
if(!this.filters.Remove(filter))
{
return false;
}
Candidate can = this.candidates[filter];
#pragma warning suppress 56506 // [....], PrefixEndpointAddressMessageFilter.Address can never be null
Uri soapToAddress = filter.Address.Uri;
CandidateSet cset = null;
if (TryMatchCandidateSet(soapToAddress, filter.IncludeHostNameInComparison, out cset))
{
if (cset.candidates.Count == 1)
{
GetAddressTable(filter.IncludeHostNameInComparison).UnregisterUri(soapToAddress, GetComparisonMode(filter.IncludeHostNameInComparison));
}
else
{
DecrementQNameCount(cset, filter.Address);
// Remove Candidate
cset.candidates.Remove(can);
}
}
this.candidates.Remove(filter);
RebuildMasks();
return true;
}
}
}
// 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
- SqlDataSourceConnectionPanel.cs
- ConfigurationErrorsException.cs
- QilValidationVisitor.cs
- DebugHandleTracker.cs
- DataGridToolTip.cs
- ServerValidateEventArgs.cs
- ScaleTransform.cs
- BaseDataBoundControl.cs
- CompiledRegexRunner.cs
- RouteValueDictionary.cs
- NotImplementedException.cs
- ValidateNames.cs
- Int32Converter.cs
- Int32KeyFrameCollection.cs
- BasicExpandProvider.cs
- GeneratedCodeAttribute.cs
- Classification.cs
- ActivityExecutionContext.cs
- HyperLink.cs
- TimeZone.cs
- RequestCacheValidator.cs
- CacheChildrenQuery.cs
- Point.cs
- OleDbRowUpdatedEvent.cs
- XPathAncestorIterator.cs
- FixedPosition.cs
- QilUnary.cs
- RowType.cs
- WindowsListViewGroupSubsetLink.cs
- ManipulationStartedEventArgs.cs
- SigningDialog.cs
- RelationshipFixer.cs
- CursorInteropHelper.cs
- PointLightBase.cs
- DependencySource.cs
- UnauthorizedWebPart.cs
- WebBrowserUriTypeConverter.cs
- AuthorizationRule.cs
- FlowDocument.cs
- XmlConvert.cs
- EntityDataSourceReferenceGroup.cs
- Facet.cs
- CommandValueSerializer.cs
- WebPartTransformerAttribute.cs
- Queue.cs
- ObjectAnimationUsingKeyFrames.cs
- BindingsCollection.cs
- XmlNode.cs
- CompilerScopeManager.cs
- EventRouteFactory.cs
- RemoteWebConfigurationHost.cs
- WebPartVerb.cs
- PngBitmapEncoder.cs
- XsdDuration.cs
- CqlBlock.cs
- XmlWrappingReader.cs
- WebBrowserProgressChangedEventHandler.cs
- WinCategoryAttribute.cs
- XamlFigureLengthSerializer.cs
- PackageStore.cs
- WebPartEditorApplyVerb.cs
- SmiEventSink_Default.cs
- DetailsViewDeleteEventArgs.cs
- BufferModeSettings.cs
- WeakReadOnlyCollection.cs
- _CacheStreams.cs
- ListSortDescription.cs
- AppendHelper.cs
- XmlNamespaceDeclarationsAttribute.cs
- EntityWithChangeTrackerStrategy.cs
- NotifyInputEventArgs.cs
- RectAnimationBase.cs
- NavigationService.cs
- XmlMembersMapping.cs
- ContentType.cs
- VisualCollection.cs
- TransactionManager.cs
- DataObjectAttribute.cs
- ChannelSinkStacks.cs
- ParallelEnumerableWrapper.cs
- ColorTranslator.cs
- SolidColorBrush.cs
- DynamicField.cs
- Timer.cs
- InkCanvasInnerCanvas.cs
- FieldMetadata.cs
- PersonalizationState.cs
- ChannelSinkStacks.cs
- FilterEventArgs.cs
- MeasurementDCInfo.cs
- PublisherMembershipCondition.cs
- ArglessEventHandlerProxy.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- MSAANativeProvider.cs
- ServiceInfo.cs
- WSFederationHttpBindingCollectionElement.cs
- SettingsAttributeDictionary.cs
- WebPartZoneCollection.cs
- HttpHandler.cs
- RootAction.cs