Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / PeerCustomResolverBindingElement.cs / 1 / PeerCustomResolverBindingElement.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.Channels
{
using System.ComponentModel;
using System.ServiceModel;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.PeerResolvers;
public sealed class PeerCustomResolverBindingElement : PeerResolverBindingElement
{
EndpointAddress address;
Binding binding;
string bindingSection, bindingConfiguration;
//this should be PeerCustomResolver?
PeerResolver resolver;
ClientCredentials credentials;
PeerReferralPolicy referralPolicy;
public PeerCustomResolverBindingElement() { }
public PeerCustomResolverBindingElement(PeerCustomResolverBindingElement other) : base(other)
{
this.address = other.address;
this.bindingConfiguration= other.bindingConfiguration;
this.bindingSection = other.bindingSection;
this.binding = other.binding;
this.resolver = other.resolver;
this.credentials = other.credentials;
}
public PeerCustomResolverBindingElement(PeerCustomResolverSettings settings)
{
if(settings != null)
{
this.address = settings.Address;
this.binding = settings.Binding;
this.resolver = settings.Resolver;
this.bindingConfiguration = settings.BindingConfiguration;
this.bindingSection = settings.BindingSection;
}
}
public PeerCustomResolverBindingElement(BindingContext context, PeerCustomResolverSettings settings):this(settings)
{
if (context == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("context"));
#pragma warning suppress 56506 //
credentials = context.BindingParameters.Find();
}
public override T GetProperty(System.ServiceModel.Channels.BindingContext context)
{
#pragma warning suppress 56506 //
return context.GetInnerProperty();
}
public EndpointAddress Address
{
get
{
return address;
}
set
{
address = value;
}
}
public Binding Binding
{
get
{
return binding;
}
set
{
binding = value;
}
}
public override PeerReferralPolicy ReferralPolicy
{
get
{
return referralPolicy;
}
set
{
if(!PeerReferralPolicyHelper.IsDefined(value))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("value", (int)value, typeof(PeerReferralPolicy)));
}
referralPolicy = value;
}
}
public override BindingElement Clone()
{
return new PeerCustomResolverBindingElement(this);
}
public override IChannelFactory BuildChannelFactory(BindingContext context)
{
if (context == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("context"));
#pragma warning suppress 56506 //
context.BindingParameters.Add(this);
credentials = context.BindingParameters.Find();
return context.BuildInnerChannelFactory();
}
public override bool CanBuildChannelFactory(BindingContext context)
{
if (context == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("context"));
#pragma warning suppress 56506 //
this.credentials = context.BindingParameters.Find();
context.BindingParameters.Add(this);
return context.CanBuildInnerChannelFactory();
}
public override IChannelListener BuildChannelListener(BindingContext context)
{
if (context == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("context"));
#pragma warning suppress 56506 //
context.BindingParameters.Add(this);
this.credentials = context.BindingParameters.Find();
return context.BuildInnerChannelListener();
}
public override bool CanBuildChannelListener(BindingContext context)
{
if (context == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("context"));
#pragma warning suppress 56506 //
this.credentials = context.BindingParameters.Find();
context.BindingParameters.Add(this);
return context.CanBuildInnerChannelListener();
}
public override PeerResolver CreatePeerResolver()
{
if(resolver == null)
{
if(address == null || ((binding == null) && (String.IsNullOrEmpty(this.bindingSection) || String.IsNullOrEmpty(this.bindingConfiguration))))
PeerExceptionHelper.ThrowArgument_InsufficientResolverSettings();
if (binding == null)
{
this.binding = ConfigLoader.LookupBinding(this.bindingSection, this.bindingConfiguration);
if (binding == null)
PeerExceptionHelper.ThrowArgument_InsufficientResolverSettings();
}
resolver = new PeerDefaultCustomResolverClient();
}
if (resolver != null)
{
resolver.Initialize(address, binding, credentials, this.referralPolicy);
if (resolver is PeerDefaultCustomResolverClient)
{
(resolver as PeerDefaultCustomResolverClient).BindingName = this.bindingSection;
(resolver as PeerDefaultCustomResolverClient).BindingConfigurationName = this.bindingConfiguration;
}
}
return resolver;
}
}
}
// 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
- UrlMappingCollection.cs
- SqlDataSourceConnectionPanel.cs
- Win32Exception.cs
- GridViewDeletedEventArgs.cs
- InternalResources.cs
- WpfSharedXamlSchemaContext.cs
- ContextInformation.cs
- RepeaterItem.cs
- BinaryUtilClasses.cs
- Journaling.cs
- ListViewItem.cs
- SafeUserTokenHandle.cs
- PrivilegedConfigurationManager.cs
- LinqDataSourceEditData.cs
- StorageInfo.cs
- Size.cs
- TracePayload.cs
- Parser.cs
- DirectoryRedirect.cs
- ExtractedStateEntry.cs
- SoapMessage.cs
- OdbcEnvironment.cs
- DrawingBrush.cs
- HtmlTableCellCollection.cs
- TreeBuilderBamlTranslator.cs
- PropertyInfoSet.cs
- UserMapPath.cs
- BamlRecordWriter.cs
- XmlHierarchicalDataSourceView.cs
- RectValueSerializer.cs
- MouseWheelEventArgs.cs
- Model3DCollection.cs
- ActiveXContainer.cs
- UserControlCodeDomTreeGenerator.cs
- HttpHeaderCollection.cs
- SafeBitVector32.cs
- GeneralTransform.cs
- util.cs
- FileDialog_Vista.cs
- StrongNameSignatureInformation.cs
- ModelVisual3D.cs
- Matrix3DStack.cs
- BaseParagraph.cs
- DefaultBinder.cs
- BigInt.cs
- ItemsControl.cs
- HostingEnvironmentException.cs
- XsltConvert.cs
- nulltextcontainer.cs
- MultiByteCodec.cs
- UserControlFileEditor.cs
- TableRowsCollectionEditor.cs
- ColorConvertedBitmapExtension.cs
- DesignTimeValidationFeature.cs
- SqlRecordBuffer.cs
- FilterElement.cs
- EntityTypeEmitter.cs
- DesigntimeLicenseContextSerializer.cs
- TextServicesProperty.cs
- OleDbTransaction.cs
- ConnectionInterfaceCollection.cs
- CultureInfo.cs
- TemplateColumn.cs
- UniqueID.cs
- ConnectionOrientedTransportManager.cs
- DataDesignUtil.cs
- RepeaterCommandEventArgs.cs
- JavaScriptObjectDeserializer.cs
- SessionState.cs
- TransactionTraceIdentifier.cs
- DataDesignUtil.cs
- HMAC.cs
- MappingMetadataHelper.cs
- _NetRes.cs
- Point3D.cs
- TextClipboardData.cs
- ColumnResult.cs
- DataSourceProvider.cs
- MetabaseServerConfig.cs
- LabelLiteral.cs
- EdmPropertyAttribute.cs
- Int32RectValueSerializer.cs
- ConfigurationCollectionAttribute.cs
- PermissionSet.cs
- NamespaceInfo.cs
- AlphabetConverter.cs
- KeyValuePair.cs
- X509UI.cs
- VisualTarget.cs
- ObjectPersistData.cs
- KeyInterop.cs
- BridgeDataReader.cs
- InputScope.cs
- MimeTypePropertyAttribute.cs
- TextSerializer.cs
- GridViewCommandEventArgs.cs
- ImmutableDispatchRuntime.cs
- EditorZone.cs
- ObjectDataProvider.cs
- storepermission.cs