Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Configuration / PeerCustomResolverElement.cs / 1 / PeerCustomResolverElement.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Configuration
{
using System.Configuration;
using System.ServiceModel.Description;
using System.Globalization;
using System.Net;
using System.Net.Security;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.PeerResolvers;
using System.ComponentModel;
public sealed partial class PeerCustomResolverElement : ConfigurationElement
{
[ConfigurationProperty(ConfigurationStrings.Address, DefaultValue = null, Options = ConfigurationPropertyOptions.None)]
public Uri Address
{
get {return (Uri) base[ConfigurationStrings.Address]; }
set {base[ConfigurationStrings.Address] = value; }
}
[ConfigurationProperty(ConfigurationStrings.Headers)]
public AddressHeaderCollectionElement Headers
{
get { return (AddressHeaderCollectionElement)base[ConfigurationStrings.Headers]; }
}
[ConfigurationProperty(ConfigurationStrings.Identity)]
public IdentityElement Identity
{
get { return (IdentityElement)base[ConfigurationStrings.Identity]; }
}
[ConfigurationProperty(ConfigurationStrings.Binding, DefaultValue = "")]
[StringValidator(MinLength = 0)]
public string Binding
{
get { return (string)base[ConfigurationStrings.Binding]; }
set { base[ConfigurationStrings.Binding] = value; }
}
[ConfigurationProperty(ConfigurationStrings.BindingConfiguration, DefaultValue = "")]
[StringValidator(MinLength = 0)]
public string BindingConfiguration
{
get { return (string)base[ConfigurationStrings.BindingConfiguration]; }
set { base[ConfigurationStrings.BindingConfiguration] = value; }
}
[ConfigurationProperty(ConfigurationStrings.PeerResolverType, DefaultValue = "")]
[StringValidator(MinLength = 0)]
public string ResolverType
{
get { return (string)base[ConfigurationStrings.PeerResolverType]; }
set { base[ConfigurationStrings.PeerResolverType] = value; }
}
internal void ApplyConfiguration(PeerCustomResolverSettings settings)
{
if (settings == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("settings");
}
if (this.Address != null)
{
settings.Address = new EndpointAddress(this.Address, ConfigLoader.LoadIdentity(this.Identity), this.Headers.Headers);
}
settings.BindingSection = this.Binding;
settings.BindingConfiguration = this.BindingConfiguration;
if (!String.IsNullOrEmpty(this.Binding) && !String.IsNullOrEmpty(this.BindingConfiguration))
settings.Binding = ConfigLoader.LookupBinding(this.Binding, this.BindingConfiguration);
if (!String.IsNullOrEmpty(this.ResolverType))
{
Type myResolverType = Type.GetType(this.ResolverType, false);
if (myResolverType != null)
{
settings.Resolver = Activator.CreateInstance(myResolverType) as PeerResolver;
}
else
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(
SR.GetString(SR.PeerResolverInvalid, this.ResolverType)));
}
}
}
internal void InitializeFrom(PeerCustomResolverSettings settings)
{
if (settings == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("settings");
}
if(settings.Address != null)
{
this.Address = settings.Address.Uri;
this.Identity.InitializeFrom(settings.Address.Identity);
}
if(settings.Resolver != null)
{
this.ResolverType = settings.Resolver.GetType().AssemblyQualifiedName;
}
if(settings.Binding != null)
{
this.BindingConfiguration = PeerStrings.PeerCustomResolver+Guid.NewGuid().ToString();
string sectionName;
BindingsSection.TryAdd(this.BindingConfiguration,
settings.Binding,
out sectionName);
this.Binding = sectionName;
}
}
}
}
// 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
- EnlistmentState.cs
- TemplateKey.cs
- ScopelessEnumAttribute.cs
- RIPEMD160.cs
- GeometryValueSerializer.cs
- CompareValidator.cs
- HttpDictionary.cs
- RelatedCurrencyManager.cs
- WebPartUtil.cs
- UnitySerializationHolder.cs
- PropertyTab.cs
- CommandID.cs
- SafeMILHandleMemoryPressure.cs
- autovalidator.cs
- SharedPersonalizationStateInfo.cs
- DocumentOrderQuery.cs
- PagesSection.cs
- ModelItemImpl.cs
- SecurityContextTokenCache.cs
- IconHelper.cs
- Exception.cs
- ConvertEvent.cs
- LedgerEntry.cs
- FileDialogCustomPlacesCollection.cs
- UserPreferenceChangingEventArgs.cs
- TextMarkerSource.cs
- Calendar.cs
- VisualTreeUtils.cs
- AutoGeneratedField.cs
- TransformCollection.cs
- EventSetter.cs
- SmtpNtlmAuthenticationModule.cs
- CoTaskMemUnicodeSafeHandle.cs
- ApplicationServiceManager.cs
- ObjectHandle.cs
- JumpItem.cs
- SequenceDesigner.cs
- MarkerProperties.cs
- StringUtil.cs
- COM2ComponentEditor.cs
- ImageFormatConverter.cs
- WpfGeneratedKnownProperties.cs
- DependencyProperty.cs
- CodeMemberEvent.cs
- ToolboxItem.cs
- SessionEndedEventArgs.cs
- BitmapEffectOutputConnector.cs
- CurrentTimeZone.cs
- PenCursorManager.cs
- StringStorage.cs
- PropertyGridCommands.cs
- TraceData.cs
- Psha1DerivedKeyGenerator.cs
- XXXOnTypeBuilderInstantiation.cs
- MDIClient.cs
- LZCodec.cs
- Block.cs
- PackUriHelper.cs
- PointKeyFrameCollection.cs
- SectionUpdates.cs
- SimpleTypeResolver.cs
- NullRuntimeConfig.cs
- CompilerScope.Storage.cs
- StringCollection.cs
- TypeElement.cs
- EmptyElement.cs
- GroupQuery.cs
- HandleValueEditor.cs
- XamlStackWriter.cs
- StdValidatorsAndConverters.cs
- ArraySegment.cs
- CompensatableTransactionScopeActivityDesigner.cs
- ModifierKeysValueSerializer.cs
- CancellationHandlerDesigner.cs
- DbProviderFactories.cs
- AutomationIdentifierGuids.cs
- AlternationConverter.cs
- StringReader.cs
- AppDomainShutdownMonitor.cs
- WmfPlaceableFileHeader.cs
- CompareValidator.cs
- ViewSimplifier.cs
- TextElementCollection.cs
- WebPartVerbCollection.cs
- MenuAdapter.cs
- BooleanConverter.cs
- ToolStripCustomTypeDescriptor.cs
- OperationDescription.cs
- InputEventArgs.cs
- SamlAuthorityBinding.cs
- ImportRequest.cs
- FixUpCollection.cs
- PostBackOptions.cs
- DtdParser.cs
- GlyphCache.cs
- BStrWrapper.cs
- WebServicesSection.cs
- BitmapEffectState.cs
- ColumnHeader.cs
- UnsafeNativeMethodsTablet.cs