You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@ -0,0 +1,48 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class CallbackDebugBehavior : IEndpointBehavior
|
||||
{
|
||||
bool includeExceptionDetailInFaults = false;
|
||||
|
||||
public CallbackDebugBehavior(bool includeExceptionDetailInFaults)
|
||||
{
|
||||
this.includeExceptionDetailInFaults = includeExceptionDetailInFaults;
|
||||
}
|
||||
|
||||
public bool IncludeExceptionDetailInFaults
|
||||
{
|
||||
get { return this.includeExceptionDetailInFaults; }
|
||||
set { this.includeExceptionDetailInFaults = value; }
|
||||
}
|
||||
|
||||
void IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
|
||||
{
|
||||
}
|
||||
void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection bindingParameters)
|
||||
{
|
||||
}
|
||||
void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint serviceEndpoint, EndpointDispatcher endpointDispatcher)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
|
||||
SR.GetString(SR.SFXEndpointBehaviorUsedOnWrongSide, typeof(CallbackDebugBehavior).Name)));
|
||||
}
|
||||
void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime behavior)
|
||||
{
|
||||
ChannelDispatcher channelDispatcher = behavior.CallbackDispatchRuntime.ChannelDispatcher;
|
||||
if (channelDispatcher != null && this.includeExceptionDetailInFaults)
|
||||
{
|
||||
channelDispatcher.IncludeExceptionDetailInFaults = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System.Runtime;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
|
||||
class CallbackTimeoutsBehavior : IEndpointBehavior
|
||||
{
|
||||
TimeSpan transactionTimeout = TimeSpan.Zero;
|
||||
|
||||
public TimeSpan TransactionTimeout
|
||||
{
|
||||
get { return this.transactionTimeout; }
|
||||
set
|
||||
{
|
||||
if (value < TimeSpan.Zero)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
|
||||
SR.GetString(SR.SFxTimeoutOutOfRange0)));
|
||||
}
|
||||
|
||||
if (TimeoutHelper.IsTooLarge(value))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
|
||||
SR.GetString(SR.SFxTimeoutOutOfRangeTooBig)));
|
||||
}
|
||||
|
||||
this.transactionTimeout = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CallbackTimeoutsBehavior()
|
||||
{
|
||||
}
|
||||
|
||||
void IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
|
||||
{
|
||||
}
|
||||
void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection bindingParameters)
|
||||
{
|
||||
}
|
||||
void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint serviceEndpoint, EndpointDispatcher endpointDispatcher)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
|
||||
SR.GetString(SR.SFXEndpointBehaviorUsedOnWrongSide, typeof(CallbackTimeoutsBehavior).Name)));
|
||||
}
|
||||
void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime behavior)
|
||||
{
|
||||
if (this.transactionTimeout != TimeSpan.Zero)
|
||||
{
|
||||
ChannelDispatcher channelDispatcher = behavior.CallbackDispatchRuntime.ChannelDispatcher;
|
||||
if ((channelDispatcher != null) &&
|
||||
(channelDispatcher.TransactionTimeout == TimeSpan.Zero) ||
|
||||
(channelDispatcher.TransactionTimeout > this.transactionTimeout))
|
||||
{
|
||||
channelDispatcher.TransactionTimeout = this.transactionTimeout;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,366 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IdentityModel.Selectors;
|
||||
using System.Runtime;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.ServiceModel.Security;
|
||||
using System.IdentityModel.Tokens;
|
||||
|
||||
public class ClientCredentials : SecurityCredentialsManager, IEndpointBehavior
|
||||
{
|
||||
internal const bool SupportInteractiveDefault = true;
|
||||
|
||||
UserNamePasswordClientCredential userName;
|
||||
X509CertificateInitiatorClientCredential clientCertificate;
|
||||
X509CertificateRecipientClientCredential serviceCertificate;
|
||||
WindowsClientCredential windows;
|
||||
HttpDigestClientCredential httpDigest;
|
||||
IssuedTokenClientCredential issuedToken;
|
||||
PeerCredential peer;
|
||||
bool supportInteractive;
|
||||
bool isReadOnly;
|
||||
GetInfoCardTokenCallback getInfoCardTokenCallback = null;
|
||||
bool useIdentityConfiguration = false;
|
||||
SecurityTokenHandlerCollectionManager securityTokenHandlerCollectionManager = null;
|
||||
object handlerCollectionLock = new object();
|
||||
|
||||
public ClientCredentials()
|
||||
{
|
||||
this.supportInteractive = SupportInteractiveDefault;
|
||||
}
|
||||
|
||||
protected ClientCredentials(ClientCredentials other)
|
||||
{
|
||||
if (other == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("other");
|
||||
if (other.userName != null)
|
||||
this.userName = new UserNamePasswordClientCredential(other.userName);
|
||||
if (other.clientCertificate != null)
|
||||
this.clientCertificate = new X509CertificateInitiatorClientCredential(other.clientCertificate);
|
||||
if (other.serviceCertificate != null)
|
||||
this.serviceCertificate = new X509CertificateRecipientClientCredential(other.serviceCertificate);
|
||||
if (other.windows != null)
|
||||
this.windows = new WindowsClientCredential(other.windows);
|
||||
if (other.httpDigest != null)
|
||||
this.httpDigest = new HttpDigestClientCredential(other.httpDigest);
|
||||
if (other.issuedToken != null)
|
||||
this.issuedToken = new IssuedTokenClientCredential(other.issuedToken);
|
||||
if (other.peer != null)
|
||||
this.peer = new PeerCredential(other.peer);
|
||||
|
||||
this.getInfoCardTokenCallback = other.getInfoCardTokenCallback;
|
||||
this.supportInteractive = other.supportInteractive;
|
||||
this.securityTokenHandlerCollectionManager = other.securityTokenHandlerCollectionManager;
|
||||
this.useIdentityConfiguration = other.useIdentityConfiguration;
|
||||
this.isReadOnly = other.isReadOnly;
|
||||
}
|
||||
|
||||
internal GetInfoCardTokenCallback GetInfoCardTokenCallback
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.getInfoCardTokenCallback == null)
|
||||
{
|
||||
GetInfoCardTokenCallback gtc = new GetInfoCardTokenCallback(this.GetInfoCardSecurityToken);
|
||||
this.getInfoCardTokenCallback = gtc;
|
||||
}
|
||||
return this.getInfoCardTokenCallback;
|
||||
}
|
||||
}
|
||||
|
||||
public IssuedTokenClientCredential IssuedToken
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.issuedToken == null)
|
||||
{
|
||||
this.issuedToken = new IssuedTokenClientCredential();
|
||||
if (isReadOnly)
|
||||
this.issuedToken.MakeReadOnly();
|
||||
}
|
||||
return this.issuedToken;
|
||||
}
|
||||
}
|
||||
|
||||
public UserNamePasswordClientCredential UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.userName == null)
|
||||
{
|
||||
this.userName = new UserNamePasswordClientCredential();
|
||||
if (isReadOnly)
|
||||
this.userName.MakeReadOnly();
|
||||
}
|
||||
return this.userName;
|
||||
}
|
||||
}
|
||||
|
||||
public X509CertificateInitiatorClientCredential ClientCertificate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.clientCertificate == null)
|
||||
{
|
||||
this.clientCertificate = new X509CertificateInitiatorClientCredential();
|
||||
if (isReadOnly)
|
||||
this.clientCertificate.MakeReadOnly();
|
||||
}
|
||||
return this.clientCertificate;
|
||||
}
|
||||
}
|
||||
|
||||
public X509CertificateRecipientClientCredential ServiceCertificate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.serviceCertificate == null)
|
||||
{
|
||||
this.serviceCertificate = new X509CertificateRecipientClientCredential();
|
||||
if (isReadOnly)
|
||||
this.serviceCertificate.MakeReadOnly();
|
||||
}
|
||||
return this.serviceCertificate;
|
||||
}
|
||||
}
|
||||
|
||||
public WindowsClientCredential Windows
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.windows == null)
|
||||
{
|
||||
this.windows = new WindowsClientCredential();
|
||||
if (isReadOnly)
|
||||
this.windows.MakeReadOnly();
|
||||
}
|
||||
return this.windows;
|
||||
}
|
||||
}
|
||||
|
||||
public HttpDigestClientCredential HttpDigest
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.httpDigest == null)
|
||||
{
|
||||
this.httpDigest = new HttpDigestClientCredential();
|
||||
if (isReadOnly)
|
||||
this.httpDigest.MakeReadOnly();
|
||||
}
|
||||
return this.httpDigest;
|
||||
}
|
||||
}
|
||||
|
||||
public PeerCredential Peer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.peer == null)
|
||||
{
|
||||
this.peer = new PeerCredential();
|
||||
if (isReadOnly)
|
||||
this.peer.MakeReadOnly();
|
||||
}
|
||||
return this.peer;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SecurityTokenHandlerCollectionManager" /> containing the set of <see cref="SecurityTokenHandler" />
|
||||
/// objects used for serializing and validating tokens found in WS-Trust messages.
|
||||
/// </summary>
|
||||
public SecurityTokenHandlerCollectionManager SecurityTokenHandlerCollectionManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.securityTokenHandlerCollectionManager == null)
|
||||
{
|
||||
lock (this.handlerCollectionLock)
|
||||
{
|
||||
if (this.securityTokenHandlerCollectionManager == null)
|
||||
{
|
||||
this.securityTokenHandlerCollectionManager = SecurityTokenHandlerCollectionManager.CreateDefaultSecurityTokenHandlerCollectionManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.securityTokenHandlerCollectionManager;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.isReadOnly)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||||
}
|
||||
|
||||
this.securityTokenHandlerCollectionManager = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseIdentityConfiguration
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.useIdentityConfiguration;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.isReadOnly)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||||
}
|
||||
this.useIdentityConfiguration = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SupportInteractive
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.supportInteractive;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.isReadOnly)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||||
}
|
||||
this.supportInteractive = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static ClientCredentials CreateDefaultCredentials()
|
||||
{
|
||||
return new ClientCredentials();
|
||||
}
|
||||
|
||||
public override SecurityTokenManager CreateSecurityTokenManager()
|
||||
{
|
||||
return new ClientCredentialsSecurityTokenManager(this.Clone());
|
||||
}
|
||||
|
||||
protected virtual ClientCredentials CloneCore()
|
||||
{
|
||||
return new ClientCredentials(this);
|
||||
}
|
||||
|
||||
public ClientCredentials Clone()
|
||||
{
|
||||
ClientCredentials result = CloneCore();
|
||||
if (result == null || result.GetType() != this.GetType())
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException(SR.GetString(SR.CloneNotImplementedCorrectly, this.GetType(), (result != null) ? result.ToString() : "null")));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
|
||||
{
|
||||
}
|
||||
|
||||
void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection bindingParameters)
|
||||
{
|
||||
if (bindingParameters == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingParameters");
|
||||
}
|
||||
// throw if bindingParameters already has a SecurityCredentialsManager
|
||||
SecurityCredentialsManager otherCredentialsManager = bindingParameters.Find<SecurityCredentialsManager>();
|
||||
if (otherCredentialsManager != null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MultipleSecurityCredentialsManagersInChannelBindingParameters, otherCredentialsManager)));
|
||||
}
|
||||
bindingParameters.Add(this);
|
||||
}
|
||||
|
||||
void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint serviceEndpoint, EndpointDispatcher endpointDispatcher)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
|
||||
SR.GetString(SR.SFXEndpointBehaviorUsedOnWrongSide, typeof(ClientCredentials).Name)));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
void AddInteractiveInitializers(ServiceEndpoint serviceEndpoint, ClientRuntime behavior)
|
||||
{
|
||||
CardSpacePolicyElement[] dummyPolicyElements;
|
||||
Uri dummyRelyingPartyIssuer;
|
||||
// we add the initializer only if infocard is required. At this point, serviceEndpoint.Address is not populated correctly but that's not needed to
|
||||
// determine whether infocard is required or not.
|
||||
if (InfoCardHelper.IsInfocardRequired(serviceEndpoint.Binding, this, this.CreateSecurityTokenManager(), EndpointAddress.AnonymousAddress, out dummyPolicyElements, out dummyRelyingPartyIssuer))
|
||||
{
|
||||
behavior.InteractiveChannelInitializers.Add(new InfocardInteractiveChannelInitializer(this, serviceEndpoint.Binding));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime behavior)
|
||||
{
|
||||
|
||||
if (serviceEndpoint == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceEndpoint");
|
||||
}
|
||||
|
||||
if (serviceEndpoint.Binding == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceEndpoint.Binding");
|
||||
}
|
||||
|
||||
|
||||
if (serviceEndpoint.Binding.CreateBindingElements().Find<SecurityBindingElement>() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AddInteractiveInitializers(serviceEndpoint, behavior);
|
||||
}
|
||||
catch (System.IO.FileNotFoundException)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// RC0 workaround to freeze credentials when the channel factory is opened
|
||||
internal void MakeReadOnly()
|
||||
{
|
||||
this.isReadOnly = true;
|
||||
if (this.clientCertificate != null)
|
||||
this.clientCertificate.MakeReadOnly();
|
||||
if (this.serviceCertificate != null)
|
||||
this.serviceCertificate.MakeReadOnly();
|
||||
if (this.userName != null)
|
||||
this.userName.MakeReadOnly();
|
||||
if (this.windows != null)
|
||||
this.windows.MakeReadOnly();
|
||||
if (this.httpDigest != null)
|
||||
this.httpDigest.MakeReadOnly();
|
||||
if (this.issuedToken != null)
|
||||
this.issuedToken.MakeReadOnly();
|
||||
if (this.peer != null)
|
||||
this.peer.MakeReadOnly();
|
||||
}
|
||||
|
||||
// This APTCA method calls CardSpaceSelector.GetToken(..), which is defined in a non-APTCA assembly. It would be a breaking change to add a Demand,
|
||||
// while we don't have an identified security vulnerability here.
|
||||
[SuppressMessage(FxCop.Category.Security, FxCop.Rule.AptcaMethodsShouldOnlyCallAptcaMethods)]
|
||||
internal protected virtual SecurityToken GetInfoCardSecurityToken(bool requiresInfoCard, CardSpacePolicyElement[] chain, SecurityTokenSerializer tokenSerializer)
|
||||
{
|
||||
if (!requiresInfoCard)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return CardSpaceSelector.GetToken(chain, tokenSerializer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ClientViaBehavior : IEndpointBehavior
|
||||
{
|
||||
Uri uri;
|
||||
|
||||
public ClientViaBehavior(Uri uri)
|
||||
{
|
||||
if (uri == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("uri");
|
||||
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public Uri Uri
|
||||
{
|
||||
get { return this.uri; }
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
|
||||
|
||||
this.uri = value;
|
||||
}
|
||||
}
|
||||
|
||||
void IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
|
||||
{
|
||||
}
|
||||
|
||||
void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection bindingParameters)
|
||||
{
|
||||
}
|
||||
|
||||
void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint serviceEndpoint, EndpointDispatcher endpointDispatcher)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
|
||||
SR.GetString(SR.SFXEndpointBehaviorUsedOnWrongSide, typeof(ClientViaBehavior).Name)));
|
||||
}
|
||||
|
||||
void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime behavior)
|
||||
{
|
||||
if (behavior == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("behavior");
|
||||
}
|
||||
|
||||
behavior.Via = this.Uri;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,112 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Configuration;
|
||||
using System.ServiceModel.Diagnostics;
|
||||
|
||||
internal class ConfigWriter
|
||||
{
|
||||
readonly Dictionary<Binding, BindingDictionaryValue> bindingTable;
|
||||
readonly BindingsSection bindingsSection;
|
||||
readonly ChannelEndpointElementCollection channels;
|
||||
readonly Configuration config;
|
||||
|
||||
internal ConfigWriter(Configuration configuration)
|
||||
{
|
||||
this.bindingTable = new Dictionary<Binding, BindingDictionaryValue>();
|
||||
|
||||
this.bindingsSection = BindingsSection.GetSection(configuration);
|
||||
|
||||
ServiceModelSectionGroup serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration);
|
||||
this.channels = serviceModelSectionGroup.Client.Endpoints;
|
||||
this.config = configuration;
|
||||
}
|
||||
|
||||
internal ChannelEndpointElement WriteChannelDescription(ServiceEndpoint endpoint, string typeName)
|
||||
{
|
||||
ChannelEndpointElement channelElement = null;
|
||||
|
||||
// Create Binding
|
||||
BindingDictionaryValue bindingDV = CreateBindingConfig(endpoint.Binding);
|
||||
|
||||
|
||||
channelElement = new ChannelEndpointElement(endpoint.Address, typeName);
|
||||
|
||||
// [....]: review: Use decoded form to preserve the user-given friendly name, however, beacuse our Encoding algorithm
|
||||
// does not touch ASCII names, a name that looks like encoded name will not roundtrip(Example: "_x002C_" will turned into ",")
|
||||
channelElement.Name = NamingHelper.GetUniqueName(NamingHelper.CodeName(endpoint.Name), this.CheckIfChannelNameInUse, null);
|
||||
|
||||
channelElement.BindingConfiguration = bindingDV.BindingName;
|
||||
channelElement.Binding = bindingDV.BindingSectionName;
|
||||
channels.Add(channelElement);
|
||||
|
||||
return channelElement;
|
||||
}
|
||||
|
||||
internal void WriteBinding(Binding binding, out string bindingSectionName, out string configurationName)
|
||||
{
|
||||
BindingDictionaryValue result = CreateBindingConfig(binding);
|
||||
|
||||
configurationName = result.BindingName;
|
||||
bindingSectionName = result.BindingSectionName;
|
||||
}
|
||||
|
||||
BindingDictionaryValue CreateBindingConfig(Binding binding)
|
||||
{
|
||||
BindingDictionaryValue bindingDV;
|
||||
if (!bindingTable.TryGetValue(binding, out bindingDV))
|
||||
{
|
||||
// [....]: review: Use decoded form to preserve the user-given friendly name, however, beacuse our Encoding algorithm
|
||||
// does not touch ASCII names, a name that looks like encoded name will not roundtrip(Example: "_x002C_" will turned into ",")
|
||||
string bindingName = NamingHelper.GetUniqueName(NamingHelper.CodeName(binding.Name), this.CheckIfBindingNameInUse, null);
|
||||
string bindingSectionName;
|
||||
|
||||
if (!BindingsSection.TryAdd(bindingName, binding, config, out bindingSectionName))
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.ConfigBindingCannotBeConfigured), "endpoint.Binding"));
|
||||
|
||||
bindingDV = new BindingDictionaryValue(bindingName, bindingSectionName);
|
||||
bindingTable.Add(binding, bindingDV);
|
||||
}
|
||||
return bindingDV;
|
||||
}
|
||||
|
||||
bool CheckIfBindingNameInUse(string name, object nameCollection)
|
||||
{
|
||||
foreach (BindingCollectionElement bindingCollectionElement in this.bindingsSection.BindingCollections)
|
||||
if (bindingCollectionElement.ContainsKey(name))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CheckIfChannelNameInUse(string name, object namingCollection)
|
||||
{
|
||||
foreach (ChannelEndpointElement element in this.channels)
|
||||
if (element.Name == name)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
sealed class BindingDictionaryValue
|
||||
{
|
||||
public readonly string BindingName;
|
||||
public readonly string BindingSectionName;
|
||||
|
||||
public BindingDictionaryValue(string bindingName, string bindingSectionName)
|
||||
{
|
||||
this.BindingName = bindingName;
|
||||
this.BindingSectionName = bindingSectionName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,256 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Security;
|
||||
using System.ServiceModel.Security;
|
||||
|
||||
[DebuggerDisplay("Name={name}, Namespace={ns}, ContractType={contractType}")]
|
||||
public class ContractDescription
|
||||
{
|
||||
Type callbackContractType;
|
||||
string configurationName;
|
||||
Type contractType;
|
||||
XmlName name;
|
||||
string ns;
|
||||
OperationDescriptionCollection operations;
|
||||
SessionMode sessionMode;
|
||||
KeyedByTypeCollection<IContractBehavior> behaviors = new KeyedByTypeCollection<IContractBehavior>();
|
||||
ProtectionLevel protectionLevel;
|
||||
bool hasProtectionLevel;
|
||||
|
||||
public ContractDescription(string name)
|
||||
: this(name, null)
|
||||
{
|
||||
}
|
||||
|
||||
public ContractDescription(string name, string ns)
|
||||
{
|
||||
// the property setter validates given value
|
||||
this.Name = name;
|
||||
if (!string.IsNullOrEmpty(ns))
|
||||
NamingHelper.CheckUriParameter(ns, "ns");
|
||||
|
||||
this.operations = new OperationDescriptionCollection();
|
||||
this.ns = ns ?? NamingHelper.DefaultNamespace; // ns can be ""
|
||||
}
|
||||
|
||||
internal string CodeName
|
||||
{
|
||||
get { return this.name.DecodedName; }
|
||||
}
|
||||
|
||||
[DefaultValue(null)]
|
||||
public string ConfigurationName
|
||||
{
|
||||
get { return this.configurationName; }
|
||||
set { this.configurationName = value; }
|
||||
}
|
||||
|
||||
public Type ContractType
|
||||
{
|
||||
get { return this.contractType; }
|
||||
set { this.contractType = value; }
|
||||
}
|
||||
|
||||
public Type CallbackContractType
|
||||
{
|
||||
get { return this.callbackContractType; }
|
||||
set { this.callbackContractType = value; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return this.name.EncodedName; }
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
|
||||
}
|
||||
|
||||
if (value.Length == 0)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new ArgumentOutOfRangeException("value", SR.GetString(SR.SFxContractDescriptionNameCannotBeEmpty)));
|
||||
}
|
||||
this.name = new XmlName(value, true /*isEncoded*/);
|
||||
}
|
||||
}
|
||||
|
||||
public string Namespace
|
||||
{
|
||||
get { return this.ns; }
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
NamingHelper.CheckUriProperty(value, "Namespace");
|
||||
this.ns = value;
|
||||
}
|
||||
}
|
||||
|
||||
public OperationDescriptionCollection Operations
|
||||
{
|
||||
get { return this.operations; }
|
||||
}
|
||||
|
||||
public ProtectionLevel ProtectionLevel
|
||||
{
|
||||
get { return this.protectionLevel; }
|
||||
set
|
||||
{
|
||||
if (!ProtectionLevelHelper.IsDefined(value))
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value"));
|
||||
this.protectionLevel = value;
|
||||
this.hasProtectionLevel = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShouldSerializeProtectionLevel()
|
||||
{
|
||||
return this.HasProtectionLevel;
|
||||
}
|
||||
|
||||
public bool HasProtectionLevel
|
||||
{
|
||||
get { return this.hasProtectionLevel; }
|
||||
}
|
||||
|
||||
[DefaultValue(SessionMode.Allowed)]
|
||||
public SessionMode SessionMode
|
||||
{
|
||||
get { return this.sessionMode; }
|
||||
set
|
||||
{
|
||||
if (!SessionModeHelper.IsDefined(value))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value"));
|
||||
}
|
||||
|
||||
this.sessionMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
public KeyedCollection<Type, IContractBehavior> ContractBehaviors
|
||||
{
|
||||
get { return this.Behaviors; }
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public KeyedByTypeCollection<IContractBehavior> Behaviors
|
||||
{
|
||||
get { return this.behaviors; }
|
||||
}
|
||||
|
||||
public static ContractDescription GetContract(Type contractType)
|
||||
{
|
||||
if (contractType == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType");
|
||||
|
||||
TypeLoader typeLoader = new TypeLoader();
|
||||
return typeLoader.LoadContractDescription(contractType);
|
||||
}
|
||||
|
||||
public static ContractDescription GetContract(Type contractType, Type serviceType)
|
||||
{
|
||||
if (contractType == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType");
|
||||
|
||||
if (serviceType == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceType");
|
||||
|
||||
TypeLoader typeLoader = new TypeLoader();
|
||||
ContractDescription description = typeLoader.LoadContractDescription(contractType, serviceType);
|
||||
return description;
|
||||
}
|
||||
|
||||
public static ContractDescription GetContract(Type contractType, object serviceImplementation)
|
||||
{
|
||||
if (contractType == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType");
|
||||
|
||||
if (serviceImplementation == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceImplementation");
|
||||
|
||||
TypeLoader typeLoader = new TypeLoader();
|
||||
Type serviceType = serviceImplementation.GetType();
|
||||
ContractDescription description = typeLoader.LoadContractDescription(contractType, serviceType, serviceImplementation);
|
||||
return description;
|
||||
}
|
||||
|
||||
public Collection<ContractDescription> GetInheritedContracts()
|
||||
{
|
||||
Collection<ContractDescription> result = new Collection<ContractDescription>();
|
||||
for (int i = 0; i < Operations.Count; i++)
|
||||
{
|
||||
OperationDescription od = Operations[i];
|
||||
if (od.DeclaringContract != this)
|
||||
{
|
||||
ContractDescription inheritedContract = od.DeclaringContract;
|
||||
if (!result.Contains(inheritedContract))
|
||||
{
|
||||
result.Add(inheritedContract);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void EnsureInvariants()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.Name))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
|
||||
SR.GetString(SR.AChannelServiceEndpointSContractSNameIsNull0)));
|
||||
}
|
||||
if (this.Namespace == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
|
||||
SR.GetString(SR.AChannelServiceEndpointSContractSNamespace0)));
|
||||
}
|
||||
if (this.Operations.Count == 0)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
|
||||
SR.GetString(SR.SFxContractHasZeroOperations, this.Name)));
|
||||
}
|
||||
bool thereIsAtLeastOneInitiatingOperation = false;
|
||||
for (int i = 0; i < this.Operations.Count; i++)
|
||||
{
|
||||
OperationDescription operationDescription = this.Operations[i];
|
||||
operationDescription.EnsureInvariants();
|
||||
if (operationDescription.IsInitiating)
|
||||
thereIsAtLeastOneInitiatingOperation = true;
|
||||
if ((!operationDescription.IsInitiating || operationDescription.IsTerminating)
|
||||
&& (this.SessionMode != SessionMode.Required))
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
|
||||
SR.GetString(SR.ContractIsNotSelfConsistentItHasOneOrMore2, this.Name)));
|
||||
}
|
||||
}
|
||||
if (!thereIsAtLeastOneInitiatingOperation)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
|
||||
SR.GetString(SR.SFxContractHasZeroInitiatingOperations, this.Name)));
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsDuplex()
|
||||
{
|
||||
for (int i = 0; i < this.operations.Count; ++i)
|
||||
{
|
||||
if (this.operations[i].IsServerInitiated())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ServiceModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using System.CodeDom;
|
||||
using WsdlNS = System.Web.Services.Description;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
public class DataContractSerializerMessageContractImporter : IWsdlImportExtension
|
||||
{
|
||||
bool enabled = true;
|
||||
internal const string GenericMessageSchemaTypeName = "MessageBody";
|
||||
internal const string GenericMessageSchemaTypeNamespace = "http://schemas.microsoft.com/Message";
|
||||
const string StreamBodySchemaTypeName = "StreamBody";
|
||||
const string StreamBodySchemaTypeNamespace = GenericMessageSchemaTypeNamespace;
|
||||
|
||||
static internal XmlQualifiedName GenericMessageTypeName = new XmlQualifiedName(GenericMessageSchemaTypeName, GenericMessageSchemaTypeNamespace);
|
||||
static internal XmlQualifiedName StreamBodyTypeName = new XmlQualifiedName(StreamBodySchemaTypeName, StreamBodySchemaTypeNamespace);
|
||||
|
||||
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext endpointContext)
|
||||
{
|
||||
if (endpointContext == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("endpointContext"));
|
||||
|
||||
if (enabled)
|
||||
MessageContractImporter.ImportMessageBinding(importer, endpointContext, typeof(MessageContractImporter.DataContractSerializerSchemaImporter));
|
||||
}
|
||||
|
||||
void IWsdlImportExtension.ImportContract(WsdlImporter importer, WsdlContractConversionContext contractContext)
|
||||
{
|
||||
if (contractContext == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("contractContext"));
|
||||
|
||||
if (enabled)
|
||||
MessageContractImporter.ImportMessageContract(importer, contractContext, MessageContractImporter.DataContractSerializerSchemaImporter.Get(importer));
|
||||
}
|
||||
|
||||
void IWsdlImportExtension.BeforeImport(WsdlNS.ServiceDescriptionCollection wsdlDocuments, XmlSchemaSet xmlSchemas, ICollection<XmlElement> policy) { }
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get { return this.enabled; }
|
||||
set { this.enabled = value; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class XmlSerializerMessageContractImporter : IWsdlImportExtension
|
||||
{
|
||||
|
||||
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext endpointContext)
|
||||
{
|
||||
if (endpointContext == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("endpointContext"));
|
||||
|
||||
MessageContractImporter.ImportMessageBinding(importer, endpointContext, typeof(MessageContractImporter.XmlSerializerSchemaImporter));
|
||||
}
|
||||
|
||||
void IWsdlImportExtension.ImportContract(WsdlImporter importer, WsdlContractConversionContext contractContext)
|
||||
{
|
||||
if (contractContext == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("contractContext"));
|
||||
|
||||
MessageContractImporter.ImportMessageContract(importer, contractContext, MessageContractImporter.XmlSerializerSchemaImporter.Get(importer));
|
||||
}
|
||||
|
||||
void IWsdlImportExtension.BeforeImport(WsdlNS.ServiceDescriptionCollection wsdlDocuments, XmlSchemaSet xmlSchemas, ICollection<XmlElement> policy) { }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,198 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.IO;
|
||||
using System.ServiceModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
|
||||
public class DataContractSerializerOperationBehavior : IOperationBehavior, IWsdlExportExtension
|
||||
{
|
||||
readonly bool builtInOperationBehavior;
|
||||
|
||||
OperationDescription operation;
|
||||
DataContractFormatAttribute dataContractFormatAttribute;
|
||||
internal bool ignoreExtensionDataObject = DataContractSerializerDefaults.IgnoreExtensionDataObject;
|
||||
bool ignoreExtensionDataObjectSetExplicit;
|
||||
internal int maxItemsInObjectGraph = DataContractSerializerDefaults.MaxItemsInObjectGraph;
|
||||
bool maxItemsInObjectGraphSetExplicit;
|
||||
IDataContractSurrogate dataContractSurrogate;
|
||||
DataContractResolver dataContractResolver;
|
||||
|
||||
public DataContractFormatAttribute DataContractFormatAttribute
|
||||
{
|
||||
get { return this.dataContractFormatAttribute; }
|
||||
}
|
||||
|
||||
public DataContractSerializerOperationBehavior(OperationDescription operation)
|
||||
: this(operation, null)
|
||||
{
|
||||
}
|
||||
|
||||
public DataContractSerializerOperationBehavior(OperationDescription operation, DataContractFormatAttribute dataContractFormatAttribute)
|
||||
{
|
||||
this.dataContractFormatAttribute = dataContractFormatAttribute ?? new DataContractFormatAttribute();
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
internal DataContractSerializerOperationBehavior(OperationDescription operation,
|
||||
DataContractFormatAttribute dataContractFormatAttribute, bool builtInOperationBehavior)
|
||||
: this(operation, dataContractFormatAttribute)
|
||||
{
|
||||
this.builtInOperationBehavior = builtInOperationBehavior;
|
||||
}
|
||||
|
||||
internal bool IsBuiltInOperationBehavior
|
||||
{
|
||||
get { return this.builtInOperationBehavior; }
|
||||
}
|
||||
|
||||
public int MaxItemsInObjectGraph
|
||||
{
|
||||
get { return maxItemsInObjectGraph; }
|
||||
set
|
||||
{
|
||||
maxItemsInObjectGraph = value;
|
||||
maxItemsInObjectGraphSetExplicit = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool MaxItemsInObjectGraphSetExplicit
|
||||
{
|
||||
get { return maxItemsInObjectGraphSetExplicit; }
|
||||
set { maxItemsInObjectGraphSetExplicit = value; }
|
||||
}
|
||||
|
||||
public bool IgnoreExtensionDataObject
|
||||
{
|
||||
get { return ignoreExtensionDataObject; }
|
||||
set
|
||||
{
|
||||
ignoreExtensionDataObject = value;
|
||||
ignoreExtensionDataObjectSetExplicit = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IgnoreExtensionDataObjectSetExplicit
|
||||
{
|
||||
get { return ignoreExtensionDataObjectSetExplicit; }
|
||||
set { ignoreExtensionDataObjectSetExplicit = value; }
|
||||
}
|
||||
|
||||
public IDataContractSurrogate DataContractSurrogate
|
||||
{
|
||||
get { return dataContractSurrogate; }
|
||||
set { dataContractSurrogate = value; }
|
||||
}
|
||||
|
||||
public DataContractResolver DataContractResolver
|
||||
{
|
||||
get { return dataContractResolver; }
|
||||
set { dataContractResolver = value; }
|
||||
}
|
||||
|
||||
public virtual XmlObjectSerializer CreateSerializer(Type type, string name, string ns, IList<Type> knownTypes)
|
||||
{
|
||||
return new DataContractSerializer(type, name, ns, knownTypes, MaxItemsInObjectGraph, IgnoreExtensionDataObject, false /*preserveObjectReferences*/, DataContractSurrogate, DataContractResolver);
|
||||
}
|
||||
|
||||
public virtual XmlObjectSerializer CreateSerializer(Type type, XmlDictionaryString name, XmlDictionaryString ns, IList<Type> knownTypes)
|
||||
{
|
||||
return new DataContractSerializer(type, name, ns, knownTypes, MaxItemsInObjectGraph, IgnoreExtensionDataObject, false /*preserveObjectReferences*/, DataContractSurrogate, DataContractResolver);
|
||||
}
|
||||
|
||||
internal object GetFormatter(OperationDescription operation, out bool formatRequest, out bool formatReply, bool isProxy)
|
||||
{
|
||||
MessageDescription request = operation.Messages[0];
|
||||
MessageDescription response = null;
|
||||
if (operation.Messages.Count == 2)
|
||||
response = operation.Messages[1];
|
||||
|
||||
formatRequest = (request != null) && !request.IsUntypedMessage;
|
||||
formatReply = (response != null) && !response.IsUntypedMessage;
|
||||
|
||||
if (formatRequest || formatReply)
|
||||
{
|
||||
if (PrimitiveOperationFormatter.IsContractSupported(operation))
|
||||
return new PrimitiveOperationFormatter(operation, dataContractFormatAttribute.Style == OperationFormatStyle.Rpc);
|
||||
else
|
||||
return new DataContractSerializerOperationFormatter(operation, dataContractFormatAttribute, this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
void IOperationBehavior.Validate(OperationDescription description)
|
||||
{
|
||||
}
|
||||
|
||||
void IOperationBehavior.AddBindingParameters(OperationDescription description, BindingParameterCollection parameters)
|
||||
{
|
||||
}
|
||||
|
||||
void IOperationBehavior.ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
|
||||
{
|
||||
if (description == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description");
|
||||
|
||||
if (dispatch == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dispatch");
|
||||
|
||||
if (dispatch.Formatter != null)
|
||||
return;
|
||||
|
||||
bool formatRequest;
|
||||
bool formatReply;
|
||||
dispatch.Formatter = (IDispatchMessageFormatter)GetFormatter(description, out formatRequest, out formatReply, false);
|
||||
dispatch.DeserializeRequest = formatRequest;
|
||||
dispatch.SerializeReply = formatReply;
|
||||
}
|
||||
|
||||
void IOperationBehavior.ApplyClientBehavior(OperationDescription description, ClientOperation proxy)
|
||||
{
|
||||
if (description == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description");
|
||||
|
||||
if (proxy == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("proxy");
|
||||
|
||||
if (proxy.Formatter != null)
|
||||
return;
|
||||
|
||||
bool formatRequest;
|
||||
bool formatReply;
|
||||
proxy.Formatter = (IClientMessageFormatter)GetFormatter(description, out formatRequest, out formatReply, true);
|
||||
proxy.SerializeRequest = formatRequest;
|
||||
proxy.DeserializeReply = formatReply;
|
||||
}
|
||||
|
||||
void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext)
|
||||
{
|
||||
if (exporter == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter");
|
||||
if (endpointContext == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext");
|
||||
|
||||
MessageContractExporter.ExportMessageBinding(exporter, endpointContext, typeof(DataContractSerializerMessageContractExporter), this.operation);
|
||||
}
|
||||
|
||||
void IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext contractContext)
|
||||
{
|
||||
if (exporter == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter");
|
||||
if (contractContext == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractContext");
|
||||
|
||||
new DataContractSerializerMessageContractExporter(exporter, contractContext, this.operation, this).ExportMessageContract();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,271 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System.CodeDom;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Runtime;
|
||||
using System.Runtime.Serialization;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
|
||||
class DataContractSerializerOperationGenerator : IOperationBehavior, IOperationContractGenerationExtension
|
||||
{
|
||||
Dictionary<OperationDescription, DataContractFormatAttribute> operationAttributes = new Dictionary<OperationDescription, DataContractFormatAttribute>();
|
||||
OperationGenerator operationGenerator;
|
||||
Dictionary<MessagePartDescription, ICollection<CodeTypeReference>> knownTypes;
|
||||
Dictionary<MessagePartDescription, bool> isNonNillableReferenceTypes;
|
||||
CodeCompileUnit codeCompileUnit;
|
||||
|
||||
public DataContractSerializerOperationGenerator() : this(new CodeCompileUnit()) { }
|
||||
public DataContractSerializerOperationGenerator(CodeCompileUnit codeCompileUnit)
|
||||
{
|
||||
this.codeCompileUnit = codeCompileUnit;
|
||||
this.operationGenerator = new OperationGenerator();
|
||||
}
|
||||
|
||||
internal void Add(MessagePartDescription part, CodeTypeReference typeReference, ICollection<CodeTypeReference> knownTypeReferences, bool isNonNillableReferenceType)
|
||||
{
|
||||
OperationGenerator.ParameterTypes.Add(part, typeReference);
|
||||
if (knownTypeReferences != null)
|
||||
KnownTypes.Add(part, knownTypeReferences);
|
||||
if (isNonNillableReferenceType)
|
||||
{
|
||||
if (isNonNillableReferenceTypes == null)
|
||||
isNonNillableReferenceTypes = new Dictionary<MessagePartDescription, bool>();
|
||||
isNonNillableReferenceTypes.Add(part, isNonNillableReferenceType);
|
||||
}
|
||||
}
|
||||
|
||||
internal OperationGenerator OperationGenerator
|
||||
{
|
||||
get { return this.operationGenerator; }
|
||||
}
|
||||
|
||||
internal Dictionary<OperationDescription, DataContractFormatAttribute> OperationAttributes
|
||||
{
|
||||
get { return operationAttributes; }
|
||||
}
|
||||
|
||||
internal Dictionary<MessagePartDescription, ICollection<CodeTypeReference>> KnownTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.knownTypes == null)
|
||||
this.knownTypes = new Dictionary<MessagePartDescription, ICollection<CodeTypeReference>>();
|
||||
return this.knownTypes;
|
||||
}
|
||||
}
|
||||
|
||||
void IOperationBehavior.Validate(OperationDescription description)
|
||||
{
|
||||
}
|
||||
|
||||
void IOperationBehavior.ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch) { }
|
||||
|
||||
void IOperationBehavior.ApplyClientBehavior(OperationDescription description, ClientOperation proxy) { }
|
||||
|
||||
void IOperationBehavior.AddBindingParameters(OperationDescription description, BindingParameterCollection parameters) { }
|
||||
|
||||
// Assumption: gets called exactly once per operation
|
||||
void IOperationContractGenerationExtension.GenerateOperation(OperationContractGenerationContext context)
|
||||
{
|
||||
DataContractSerializerOperationBehavior DataContractSerializerOperationBehavior = context.Operation.Behaviors.Find<DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior;
|
||||
DataContractFormatAttribute dataContractFormatAttribute = (DataContractSerializerOperationBehavior == null) ? new DataContractFormatAttribute() : DataContractSerializerOperationBehavior.DataContractFormatAttribute;
|
||||
OperationFormatStyle style = dataContractFormatAttribute.Style;
|
||||
operationGenerator.GenerateOperation(context, ref style, false/*isEncoded*/, new WrappedBodyTypeGenerator(this, context), knownTypes);
|
||||
dataContractFormatAttribute.Style = style;
|
||||
if (dataContractFormatAttribute.Style != TypeLoader.DefaultDataContractFormatAttribute.Style)
|
||||
context.SyncMethod.CustomAttributes.Add(OperationGenerator.GenerateAttributeDeclaration(context.Contract.ServiceContractGenerator, dataContractFormatAttribute));
|
||||
if (knownTypes != null)
|
||||
{
|
||||
Dictionary<CodeTypeReference, object> operationKnownTypes = new Dictionary<CodeTypeReference, object>(new CodeTypeReferenceComparer());
|
||||
foreach (MessageDescription message in context.Operation.Messages)
|
||||
{
|
||||
foreach (MessagePartDescription part in message.Body.Parts)
|
||||
AddKnownTypesForPart(context, part, operationKnownTypes);
|
||||
foreach (MessageHeaderDescription header in message.Headers)
|
||||
AddKnownTypesForPart(context, header, operationKnownTypes);
|
||||
if (OperationFormatter.IsValidReturnValue(message.Body.ReturnValue))
|
||||
AddKnownTypesForPart(context, message.Body.ReturnValue, operationKnownTypes);
|
||||
}
|
||||
}
|
||||
UpdateTargetCompileUnit(context, this.codeCompileUnit);
|
||||
}
|
||||
|
||||
void AddKnownTypesForPart(OperationContractGenerationContext context, MessagePartDescription part, Dictionary<CodeTypeReference, object> operationKnownTypes)
|
||||
{
|
||||
ICollection<CodeTypeReference> knownTypesForPart;
|
||||
if (knownTypes.TryGetValue(part, out knownTypesForPart))
|
||||
{
|
||||
foreach (CodeTypeReference knownTypeReference in knownTypesForPart)
|
||||
{
|
||||
object value;
|
||||
if (!operationKnownTypes.TryGetValue(knownTypeReference, out value))
|
||||
{
|
||||
operationKnownTypes.Add(knownTypeReference, null);
|
||||
CodeAttributeDeclaration knownTypeAttribute = new CodeAttributeDeclaration(typeof(ServiceKnownTypeAttribute).FullName);
|
||||
knownTypeAttribute.Arguments.Add(new CodeAttributeArgument(new CodeTypeOfExpression(knownTypeReference)));
|
||||
context.SyncMethod.CustomAttributes.Add(knownTypeAttribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void UpdateTargetCompileUnit(OperationContractGenerationContext context, CodeCompileUnit codeCompileUnit)
|
||||
{
|
||||
CodeCompileUnit targetCompileUnit = context.ServiceContractGenerator.TargetCompileUnit;
|
||||
if (!Object.ReferenceEquals(targetCompileUnit, codeCompileUnit))
|
||||
{
|
||||
foreach (CodeNamespace codeNamespace in codeCompileUnit.Namespaces)
|
||||
if (!targetCompileUnit.Namespaces.Contains(codeNamespace))
|
||||
targetCompileUnit.Namespaces.Add(codeNamespace);
|
||||
foreach (string referencedAssembly in codeCompileUnit.ReferencedAssemblies)
|
||||
if (!targetCompileUnit.ReferencedAssemblies.Contains(referencedAssembly))
|
||||
targetCompileUnit.ReferencedAssemblies.Add(referencedAssembly);
|
||||
foreach (CodeAttributeDeclaration assemblyCustomAttribute in codeCompileUnit.AssemblyCustomAttributes)
|
||||
if (!targetCompileUnit.AssemblyCustomAttributes.Contains(assemblyCustomAttribute))
|
||||
targetCompileUnit.AssemblyCustomAttributes.Add(assemblyCustomAttribute);
|
||||
foreach (CodeDirective startDirective in codeCompileUnit.StartDirectives)
|
||||
if (!targetCompileUnit.StartDirectives.Contains(startDirective))
|
||||
targetCompileUnit.StartDirectives.Add(startDirective);
|
||||
foreach (CodeDirective endDirective in codeCompileUnit.EndDirectives)
|
||||
if (!targetCompileUnit.EndDirectives.Contains(endDirective))
|
||||
targetCompileUnit.EndDirectives.Add(endDirective);
|
||||
foreach (DictionaryEntry userData in codeCompileUnit.UserData)
|
||||
targetCompileUnit.UserData[userData.Key] = userData.Value;
|
||||
}
|
||||
}
|
||||
|
||||
internal class WrappedBodyTypeGenerator : IWrappedBodyTypeGenerator
|
||||
{
|
||||
static CodeTypeReference dataContractAttributeTypeRef = new CodeTypeReference(typeof(DataContractAttribute));
|
||||
int memberCount;
|
||||
OperationContractGenerationContext context;
|
||||
DataContractSerializerOperationGenerator dataContractSerializerOperationGenerator;
|
||||
public void ValidateForParameterMode(OperationDescription operation)
|
||||
{
|
||||
if (dataContractSerializerOperationGenerator.isNonNillableReferenceTypes == null)
|
||||
return;
|
||||
foreach (MessageDescription messageDescription in operation.Messages)
|
||||
{
|
||||
if (messageDescription.Body != null)
|
||||
{
|
||||
if (messageDescription.Body.ReturnValue != null)
|
||||
ValidateForParameterMode(messageDescription.Body.ReturnValue);
|
||||
foreach (MessagePartDescription bodyPart in messageDescription.Body.Parts)
|
||||
{
|
||||
ValidateForParameterMode(bodyPart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ValidateForParameterMode(MessagePartDescription part)
|
||||
{
|
||||
if (dataContractSerializerOperationGenerator.isNonNillableReferenceTypes.ContainsKey(part))
|
||||
{
|
||||
ParameterModeException parameterModeException = new ParameterModeException(SR.GetString(SR.SFxCannotImportAsParameters_ElementIsNotNillable, part.Name, part.Namespace));
|
||||
parameterModeException.MessageContractType = MessageContractType.BareMessageContract;
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(parameterModeException);
|
||||
}
|
||||
}
|
||||
|
||||
public WrappedBodyTypeGenerator(DataContractSerializerOperationGenerator dataContractSerializerOperationGenerator, OperationContractGenerationContext context)
|
||||
{
|
||||
this.context = context;
|
||||
this.dataContractSerializerOperationGenerator = dataContractSerializerOperationGenerator;
|
||||
}
|
||||
|
||||
public void AddMemberAttributes(XmlName messageName, MessagePartDescription part, CodeAttributeDeclarationCollection attributesImported, CodeAttributeDeclarationCollection typeAttributes, CodeAttributeDeclarationCollection fieldAttributes)
|
||||
{
|
||||
CodeAttributeDeclaration dataContractAttributeDecl = null;
|
||||
foreach (CodeAttributeDeclaration attr in typeAttributes)
|
||||
{
|
||||
if (attr.AttributeType.BaseType == dataContractAttributeTypeRef.BaseType)
|
||||
{
|
||||
dataContractAttributeDecl = attr;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (dataContractAttributeDecl == null)
|
||||
{
|
||||
Fx.Assert(String.Format(CultureInfo.InvariantCulture, "Cannot find DataContract attribute for {0}", messageName));
|
||||
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(String.Format(CultureInfo.InvariantCulture, "Cannot find DataContract attribute for {0}", messageName)));
|
||||
}
|
||||
bool nsAttrFound = false;
|
||||
foreach (CodeAttributeArgument attrArg in dataContractAttributeDecl.Arguments)
|
||||
{
|
||||
if (attrArg.Name == "Namespace")
|
||||
{
|
||||
nsAttrFound = true;
|
||||
string nsValue = ((CodePrimitiveExpression)attrArg.Value).Value.ToString();
|
||||
if (nsValue != part.Namespace)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxWrapperTypeHasMultipleNamespaces, messageName)));
|
||||
}
|
||||
}
|
||||
if (!nsAttrFound)
|
||||
dataContractAttributeDecl.Arguments.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(part.Namespace)));
|
||||
|
||||
DataMemberAttribute dataMemberAttribute = new DataMemberAttribute();
|
||||
dataMemberAttribute.Order = memberCount++;
|
||||
dataMemberAttribute.EmitDefaultValue = !IsNonNillableReferenceType(part);
|
||||
fieldAttributes.Add(OperationGenerator.GenerateAttributeDeclaration(context.Contract.ServiceContractGenerator, dataMemberAttribute));
|
||||
|
||||
}
|
||||
|
||||
private bool IsNonNillableReferenceType(MessagePartDescription part)
|
||||
{
|
||||
if (dataContractSerializerOperationGenerator.isNonNillableReferenceTypes == null)
|
||||
return false;
|
||||
return dataContractSerializerOperationGenerator.isNonNillableReferenceTypes.ContainsKey(part);
|
||||
}
|
||||
|
||||
public void AddTypeAttributes(string messageName, string typeNS, CodeAttributeDeclarationCollection typeAttributes, bool isEncoded)
|
||||
{
|
||||
typeAttributes.Add(OperationGenerator.GenerateAttributeDeclaration(context.Contract.ServiceContractGenerator, new DataContractAttribute()));
|
||||
memberCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
class CodeTypeReferenceComparer : IEqualityComparer<CodeTypeReference>
|
||||
{
|
||||
public bool Equals(CodeTypeReference x, CodeTypeReference y)
|
||||
{
|
||||
if (Object.ReferenceEquals(x, y))
|
||||
return true;
|
||||
|
||||
if (x == null || y == null || x.ArrayRank != y.ArrayRank || x.BaseType != y.BaseType)
|
||||
return false;
|
||||
|
||||
CodeTypeReferenceCollection xTypeArgs = x.TypeArguments;
|
||||
CodeTypeReferenceCollection yTypeArgs = y.TypeArguments;
|
||||
if (yTypeArgs.Count == xTypeArgs.Count)
|
||||
{
|
||||
foreach (CodeTypeReference xTypeArg in xTypeArgs)
|
||||
{
|
||||
foreach (CodeTypeReference yTypeArg in yTypeArgs)
|
||||
{
|
||||
if (!this.Equals(xTypeArg, xTypeArg))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int GetHashCode(CodeTypeReference obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,59 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.ServiceModel.Channels;
|
||||
|
||||
public class DispatcherSynchronizationBehavior : IEndpointBehavior
|
||||
{
|
||||
public DispatcherSynchronizationBehavior() :
|
||||
this(false, MultipleReceiveBinder.MultipleReceiveDefaults.MaxPendingReceives)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DispatcherSynchronizationBehavior(bool asynchronousSendEnabled, int maxPendingReceives)
|
||||
{
|
||||
this.AsynchronousSendEnabled = asynchronousSendEnabled;
|
||||
this.MaxPendingReceives = maxPendingReceives;
|
||||
}
|
||||
|
||||
public bool AsynchronousSendEnabled
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public int MaxPendingReceives
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
void IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
|
||||
{
|
||||
}
|
||||
|
||||
void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection parameters)
|
||||
{
|
||||
}
|
||||
|
||||
void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint serviceEndpoint, EndpointDispatcher endpointDispatcher)
|
||||
{
|
||||
if (endpointDispatcher == null)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointDispatcher");
|
||||
}
|
||||
|
||||
endpointDispatcher.ChannelDispatcher.SendAsynchronously = this.AsynchronousSendEnabled;
|
||||
endpointDispatcher.ChannelDispatcher.MaxPendingReceives = this.MaxPendingReceives;
|
||||
}
|
||||
|
||||
void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime behavior)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.Runtime.Serialization;
|
||||
using System.CodeDom;
|
||||
using System.ServiceModel.Security;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Security;
|
||||
|
||||
[DebuggerDisplay("Name={name}, Action={action}, DetailType={detailType}")]
|
||||
public class FaultDescription
|
||||
{
|
||||
string action;
|
||||
Type detailType;
|
||||
CodeTypeReference detailTypeReference;
|
||||
XmlName elementName;
|
||||
XmlName name;
|
||||
string ns;
|
||||
ProtectionLevel protectionLevel;
|
||||
bool hasProtectionLevel;
|
||||
|
||||
public FaultDescription(string action)
|
||||
{
|
||||
if (action == null)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("action"));
|
||||
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public string Action
|
||||
{
|
||||
get { return action; }
|
||||
internal set { action = value; }
|
||||
}
|
||||
|
||||
// Not serializable on purpose, metadata import/export cannot
|
||||
// produce it, only available when binding to runtime
|
||||
public Type DetailType
|
||||
{
|
||||
get { return detailType; }
|
||||
set { detailType = value; }
|
||||
}
|
||||
|
||||
internal CodeTypeReference DetailTypeReference
|
||||
{
|
||||
get { return detailTypeReference; }
|
||||
set { detailTypeReference = value; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name.EncodedName; }
|
||||
set { SetNameAndElement(new XmlName(value, true /*isEncoded*/)); }
|
||||
}
|
||||
|
||||
public string Namespace
|
||||
{
|
||||
get { return ns; }
|
||||
set { ns = value; }
|
||||
}
|
||||
|
||||
internal XmlName ElementName
|
||||
{
|
||||
get { return elementName; }
|
||||
set { elementName = value; }
|
||||
}
|
||||
|
||||
public ProtectionLevel ProtectionLevel
|
||||
{
|
||||
get { return this.protectionLevel; }
|
||||
set
|
||||
{
|
||||
if (!ProtectionLevelHelper.IsDefined(value))
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value"));
|
||||
this.protectionLevel = value;
|
||||
this.hasProtectionLevel = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShouldSerializeProtectionLevel()
|
||||
{
|
||||
return this.HasProtectionLevel;
|
||||
}
|
||||
|
||||
public bool HasProtectionLevel
|
||||
{
|
||||
get { return this.hasProtectionLevel; }
|
||||
}
|
||||
|
||||
internal void ResetProtectionLevel()
|
||||
{
|
||||
this.protectionLevel = ProtectionLevel.None;
|
||||
this.hasProtectionLevel = false;
|
||||
}
|
||||
|
||||
internal void SetNameAndElement(XmlName name)
|
||||
{
|
||||
this.elementName = this.name = name;
|
||||
}
|
||||
|
||||
internal void SetNameOnly(XmlName name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
public class FaultDescriptionCollection : Collection<FaultDescription>
|
||||
{
|
||||
internal FaultDescriptionCollection()
|
||||
{
|
||||
}
|
||||
|
||||
public FaultDescription Find(string action)
|
||||
{
|
||||
foreach (FaultDescription description in this)
|
||||
{
|
||||
if (description != null && action == description.Action)
|
||||
return description;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Collection<FaultDescription> FindAll(string action)
|
||||
{
|
||||
Collection<FaultDescription> descriptions = new Collection<FaultDescription>();
|
||||
foreach (FaultDescription description in this)
|
||||
{
|
||||
if (description != null && action == description.Action)
|
||||
descriptions.Add(description);
|
||||
}
|
||||
|
||||
return descriptions;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System.Net.Security;
|
||||
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
[MessageContract(IsWrapped = false)]
|
||||
internal class GetResponse
|
||||
{
|
||||
MetadataSet metadataSet;
|
||||
|
||||
internal GetResponse() { }
|
||||
internal GetResponse(MetadataSet metadataSet)
|
||||
: this()
|
||||
{
|
||||
this.metadataSet = metadataSet;
|
||||
}
|
||||
|
||||
[MessageBodyMember(Name = MetadataStrings.MetadataExchangeStrings.Metadata, Namespace = MetadataStrings.MetadataExchangeStrings.Namespace)]
|
||||
internal MetadataSet Metadata
|
||||
{
|
||||
get { return this.metadataSet; }
|
||||
set { this.metadataSet = value; }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public interface IContractBehavior
|
||||
{
|
||||
void Validate(ContractDescription contractDescription, ServiceEndpoint endpoint);
|
||||
void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime);
|
||||
void ApplyClientBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, ClientRuntime clientRuntime);
|
||||
void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
// By default, when the TypeLoader sees an IContractBehavior attribute on a service implementation class,
|
||||
// it will add that behavior to each contract (endpoint) the service implements. But if the attribute
|
||||
// implements the interface below, then the TypeLoader will only add the behavior to the applicable contracts.
|
||||
public interface IContractBehaviorAttribute {
|
||||
Type TargetContract { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//----------------------------------------------------------------------------
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System;
|
||||
|
||||
interface IContractResolver
|
||||
{
|
||||
ContractDescription ResolveContract(string contractName);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Dispatcher;
|
||||
|
||||
public interface IEndpointBehavior
|
||||
{
|
||||
void Validate(ServiceEndpoint endpoint);
|
||||
void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters);
|
||||
void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher);
|
||||
void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user