Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,54 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Activation
{
using System.CodeDom.Compiler;
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Web.Compilation;
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "instantiated from config")]
[BuildProviderAppliesTo(BuildProviderAppliesTo.All)]
[ServiceActivationBuildProvider]
class WorkflowServiceBuildProvider : BuildProvider
{
internal const string ruleFileExtension = ".rules";
object[] virtualPathDependencies;
public override ICollection VirtualPathDependencies
{
get
{
if (this.virtualPathDependencies == null)
{
ArrayList dependencies = new ArrayList(base.VirtualPathDependencies.Count + 1);
dependencies.AddRange(base.VirtualPathDependencies);
dependencies.Add(Path.ChangeExtension(base.VirtualPath, ruleFileExtension));
this.virtualPathDependencies = dependencies.ToArray();
}
return virtualPathDependencies;
}
}
Type ServiceHostFactoryType
{
get
{
return typeof(WorkflowServiceHostFactory);
}
}
//CompileStringTemplate : "__VIRTUAL_PATH__|__FACTORY_NAME__|__SERVICE_VALUE__";
public override string GetCustomString(CompilerResults results)
{
return (base.VirtualPath + "|" + ServiceHostFactoryType.AssemblyQualifiedName + "|" + base.VirtualPath);
}
public override BuildProviderResultFlags GetResultFlags(CompilerResults results)
{
return BuildProviderResultFlags.ShutdownAppDomainOnChange;
}
}
}

View File

@@ -0,0 +1,206 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Activation
{
using System.Web;
using System.Web.Hosting;
using System.IO;
using System.ServiceModel.Diagnostics;
using System.Web.Compilation;
using System.Reflection;
using System.Workflow.Runtime;
using System.Workflow.ComponentModel.Compiler;
using System.Diagnostics;
[Obsolete("The WF3 types are deprecated. Instead, please use the new WF4 types from System.Activities.*")]
public class WorkflowServiceHostFactory : ServiceHostFactoryBase
{
TypeProvider typeProvider;
public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses)
{
WorkflowDefinitionContext workflowDefinitionContext = null;
Stream workflowDefinitionStream = null;
Stream ruleDefinitionStream = null;
if (string.IsNullOrEmpty(constructorString))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.WorkflowServiceHostFactoryConstructorStringNotProvided)));
}
if (!HostingEnvironment.IsHosted)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.ProcessNotExecutingUnderHostedContext)));
}
Type workflowType = this.GetTypeFromString(constructorString, baseAddresses);
if (workflowType != null)
{
workflowDefinitionContext = new CompiledWorkflowDefinitionContext(workflowType);
}
else
{
try
{
IDisposable impersonationContext = null;
try
{
try
{
}
finally
{
//Ensure thread.Abort doesnt interfere b/w impersonate & assignment.
impersonationContext = HostingEnvironment.Impersonate();
}
string xomlVirtualPath = Path.Combine(AspNetEnvironment.Current.CurrentVirtualPath, constructorString);
if (HostingEnvironment.VirtualPathProvider.FileExists(xomlVirtualPath))
{
workflowDefinitionStream = HostingEnvironment.VirtualPathProvider.GetFile(xomlVirtualPath).Open();
string ruleFilePath = Path.ChangeExtension(xomlVirtualPath, WorkflowServiceBuildProvider.ruleFileExtension);
if (HostingEnvironment.VirtualPathProvider.FileExists(ruleFilePath))
{
ruleDefinitionStream = HostingEnvironment.VirtualPathProvider.GetFile(ruleFilePath).Open();
workflowDefinitionContext = new StreamedWorkflowDefinitionContext(workflowDefinitionStream, ruleDefinitionStream, this.typeProvider);
}
else
{
workflowDefinitionContext = new StreamedWorkflowDefinitionContext(workflowDefinitionStream, null, this.typeProvider);
}
}
}
finally
{
if (impersonationContext != null)
{
impersonationContext.Dispose();
}
}
}
catch
{
throw; //Prevent impersonation leak through Exception Filters.
}
finally
{
if (workflowDefinitionStream != null)
{
workflowDefinitionStream.Close();
}
if (ruleDefinitionStream != null)
{
ruleDefinitionStream.Close();
}
}
}
if (workflowDefinitionContext == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.CannotResolveConstructorStringToWorkflowType, constructorString)));
}
WorkflowServiceHost serviceHost = new WorkflowServiceHost(workflowDefinitionContext, baseAddresses);
if (DiagnosticUtility.ShouldTraceInformation)
{
TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.WorkflowServiceHostCreated, SR.GetString(SR.TraceCodeWorkflowServiceHostCreated), this);
}
return serviceHost;
}
Type GetTypeFromString(string typeString, Uri[] baseAddresses)
{
if (baseAddresses == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("baseAddresses");
}
if (baseAddresses.Length == 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.BaseAddressesNotProvided)));
}
Type workflowType = Type.GetType(typeString, false);
if (workflowType == null)
{
this.typeProvider = new TypeProvider(null);
// retrieve the reference assembly names from the compiled string supplied by the build manager
string compiledString;
try
{
IDisposable impersonationContext = null;
try
{
try
{
}
finally
{
//Ensure Impersonation + Assignment is atomic w.r.t to potential Thread.Abort.
impersonationContext = HostingEnvironment.Impersonate();
}
compiledString = BuildManager.GetCompiledCustomString(baseAddresses[0].AbsolutePath);
}
finally
{
if (impersonationContext != null)
{
impersonationContext.Dispose();
}
}
}
catch
{
throw; //Prevent impersonation leak through exception filters.
}
if (string.IsNullOrEmpty(compiledString))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.InvalidCompiledString, baseAddresses[0].AbsolutePath)));
}
string[] components = compiledString.Split('|');
if (components.Length < 3)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.InvalidCompiledString, baseAddresses[0].AbsolutePath)));
}
//Walk reverse direction to increase our chance to match assembly;
for (int i = (components.Length - 1); i > 2; i--)
{
Assembly assembly = Assembly.Load(components[i]);
this.typeProvider.AddAssembly(assembly);
workflowType = assembly.GetType(typeString, false);
if (workflowType != null)
{
break;
}
}
if (workflowType == null)
{
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
this.typeProvider.AddAssembly(assembly);
workflowType = assembly.GetType(typeString, false);
if (workflowType != null)
{
break;
}
}
}
}
return workflowType;
}
}
}

View File

@@ -0,0 +1,99 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities.Description
{
using System.Activities.Statements;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.Runtime;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.Runtime.DurableInstancing;
using System.Collections.Generic;
using System.Threading;
using System.ServiceModel.Diagnostics;
using System.Activities;
[Obsolete("The WF3 types are deprecated. Instead, please use the new WF4 types from System.Activities.*")]
public class WorkflowRuntimeEndpoint : WorkflowHostingEndpoint
{
static readonly Uri baseUri = new Uri(string.Format(CultureInfo.InvariantCulture, "net.pipe://localhost/ExternalDataExchangeEndpoint/{0}/{1}",
Process.GetCurrentProcess().Id,
AppDomain.CurrentDomain.Id));
static int uriCounter = 0;
internal static readonly Binding netNamedPipeContextBinding = new CustomBinding(new ContextBindingElement(),
new BinaryMessageEncodingBindingElement(),
new NamedPipeTransportBindingElement()) { Name = "ExternalDataExchangeBinding" };
WorkflowRuntimeServicesBehavior behavior;
internal const string ExternalDataExchangeNamespace = "http://wf.microsoft.com/externaldataexchange/";
internal const string RaiseEventAction = "http://wf.microsoft.com/externaldataexchange/IExternalDataExchange/RaiseEvent";
public WorkflowRuntimeEndpoint()
: base(typeof(IExternalDataExchange))
{
base.Binding = netNamedPipeContextBinding;
string endpointUri = String.Format(CultureInfo.InvariantCulture, "{0}/{1}", baseUri, Interlocked.Increment(ref uriCounter));
base.Address = new EndpointAddress(endpointUri);
this.behavior = new WorkflowRuntimeServicesBehavior();
this.Behaviors.Add(behavior);
}
protected override Guid OnGetInstanceId(object[] inputs, OperationContext operationContext)
{
Fx.Assert(operationContext.IncomingMessageHeaders.Action == RaiseEventAction, "Message action is not RaiseEvent");
Guid instanceId = Guid.Empty;
ContextMessageProperty contextMessageProperty;
if (ContextMessageProperty.TryGet(operationContext.IncomingMessageProperties, out contextMessageProperty))
{
string stringInstanceId = null;
if (contextMessageProperty.Context.TryGetValue("instanceId", out stringInstanceId))
{
Fx.TryCreateGuid(stringInstanceId, out instanceId);
}
}
return instanceId;
}
protected override Bookmark OnResolveBookmark(object[] inputs, OperationContext operationContext, WorkflowHostingResponseContext responseContext, out object value)
{
Fx.Assert(operationContext.IncomingMessageHeaders.Action == RaiseEventAction, "Message action is not RaiseEvent");
Fx.Assert(inputs.Length >= 3, "Insufficient number of inputs");
Fx.Assert(inputs[1] is IComparable, "The queue name from ExternalDataExchangeService is not an IComparable object");
IComparable queueName = (IComparable)inputs[1];
value = inputs[2];
responseContext.SendResponse(null, null);
return new Bookmark(queueName.ToString());
}
public void AddService(object service)
{
behavior.AddService(service);
}
public void RemoveService(object service)
{
behavior.RemoveService(service);
}
public object GetService(Type serviceType)
{
return behavior.GetService(serviceType);
}
public T GetService<T>()
{
return behavior.GetService<T>();
}
}
}

View File

@@ -0,0 +1,89 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities.Description
{
using System.Activities.Statements;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.Runtime;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.Runtime.DurableInstancing;
using System.Collections.Generic;
using System.Threading;
using System.ServiceModel.Diagnostics;
[Fx.Tag.XamlVisible(false)]
class WorkflowRuntimeServicesBehavior : IEndpointBehavior
{
WorkflowRuntimeServicesExtensionProvider extensionProvider;
public WorkflowRuntimeServicesBehavior()
{
this.extensionProvider = new WorkflowRuntimeServicesExtensionProvider();
}
public void AddService(object service)
{
if (service == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("service");
}
this.extensionProvider.AddService(service);
}
public void RemoveService(object service)
{
if (service == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("service");
}
this.extensionProvider.RemoveService(service);
}
public object GetService(Type serviceType)
{
if (serviceType == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceType");
}
return this.extensionProvider.GetService(serviceType);
}
public T GetService<T>()
{
return this.extensionProvider.GetService<T>();
}
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
WorkflowServiceHost serviceHost = endpointDispatcher.ChannelDispatcher.Host as WorkflowServiceHost;
if (serviceHost != null)
{
foreach (OperationDescription operation in endpoint.Contract.Operations)
{
NetDataContractSerializerOperationBehavior netDataContractSerializerOperationBehavior =
NetDataContractSerializerOperationBehavior.ApplyTo(operation);
}
this.extensionProvider.PopulateExtensions(serviceHost, endpointDispatcher.EndpointAddress.Uri.AbsoluteUri);
}
}
public void Validate(ServiceEndpoint endpoint)
{
}
}
}

View File

@@ -0,0 +1,31 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities
{
using System.Runtime;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.Workflow.Activities;
class ExternalDataExchangeClient : ClientBase<IExternalDataExchange>
{
public ExternalDataExchangeClient(Binding binding, EndpointAddress address)
: base(binding, address)
{
ContractDescription contractDescription = this.Endpoint.Contract;
foreach (OperationDescription opDesc in contractDescription.Operations)
{
NetDataContractSerializerOperationBehavior netDataContractSerializerOperationBehavior = NetDataContractSerializerOperationBehavior.ApplyTo(opDesc);
Fx.Assert(netDataContractSerializerOperationBehavior != null, "IExternalDataExchange must use NetDataContractSerializer.");
}
}
public void RaiseEvent(ExternalDataEventArgs eventArgs, IComparable queueName, object message)
{
base.Channel.RaiseEvent(eventArgs, queueName, message);
}
}
}

View File

@@ -0,0 +1,15 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Activities
{
using System.ServiceModel;
[ServiceContract(Namespace = Description.WorkflowRuntimeEndpoint.ExternalDataExchangeNamespace)]
interface IExternalDataExchange
{
[OperationContract(IsOneWay = true, Action = Description.WorkflowRuntimeEndpoint.RaiseEventAction)]
void RaiseEvent(EventArgs eventArgs, IComparable queueName, object message);
}
}

View File

@@ -0,0 +1,65 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities
{
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel;
using System.ServiceModel.Activities.Description;
using System.ServiceModel.Channels;
using System.Workflow.Activities;
using System.Workflow.Runtime;
using System.ServiceModel.Description;
using System.ServiceModel.Diagnostics;
class WorkflowClientDeliverMessageWrapper : IDeliverMessage
{
string baseUri;
public WorkflowClientDeliverMessageWrapper(string baseUri)
{
this.baseUri = baseUri;
}
public object[] PrepareEventArgsArray(object sender, ExternalDataEventArgs eventArgs, out object workItem, out IPendingWork workHandler)
{
workItem = null;
workHandler = null;
return new object[] { sender, eventArgs };
}
[SuppressMessage(FxCop.Category.Security, FxCop.Rule.AptcaMethodsShouldOnlyCallAptcaMethods,
Justification = "Calling into already shipped assembly; can't apply APTCA")]
public void DeliverMessage(ExternalDataEventArgs eventArgs, IComparable queueName, object message, object workItem, IPendingWork workHandler)
{
if (eventArgs == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("eventArgs");
}
if (queueName == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("queueName");
}
using (ExternalDataExchangeClient desClient = new ExternalDataExchangeClient(WorkflowRuntimeEndpoint.netNamedPipeContextBinding,
new EndpointAddress(this.baseUri)))
{
using (OperationContextScope scope = new OperationContextScope((IContextChannel)desClient.InnerChannel))
{
IContextManager contextManager = desClient.InnerChannel.GetProperty<IContextManager>();
Fx.Assert(contextManager != null, "IContextManager must not be null.");
if (contextManager != null)
{
IDictionary<string, string> context = new Dictionary<string, string>();
context["instanceId"] = eventArgs.InstanceId.ToString();
contextManager.SetContext(context);
}
desClient.RaiseEvent(eventArgs, queueName, message);
}
}
}
}
}

View File

@@ -0,0 +1,79 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities
{
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.Workflow.Activities;
class WorkflowRuntimeServicesExtensionProvider
{
Dictionary<Type, object> services;
public WorkflowRuntimeServicesExtensionProvider()
{
this.services = new Dictionary<Type, object>();
}
public void AddService(object service)
{
Fx.Assert(service != null, "This should have been checked by our caller.");
this.services.Add(service.GetType(), service);
}
public void RemoveService(object service)
{
Fx.Assert(service != null, "This should have been checked by our caller.");
this.services.Remove(service.GetType());
}
[SuppressMessage(FxCop.Category.Security, FxCop.Rule.AptcaMethodsShouldOnlyCallAptcaMethods, Justification = "APTCA related issues are not relevant because this code path is not supported in partial trust.")]
public object GetService(Type serviceType)
{
object service;
if (!this.services.TryGetValue(serviceType, out service))
{
object dataExchangeService;
if (this.services.TryGetValue(typeof(ExternalDataExchangeService), out dataExchangeService))
{
Fx.Assert(dataExchangeService is ExternalDataExchangeService, "Something went wrong with our housekeeping.");
service = ((ExternalDataExchangeService)dataExchangeService).GetService(serviceType);
}
}
return service;
}
public T GetService<T>()
{
return (T)GetService(typeof(T));
}
internal void PopulateExtensions(WorkflowServiceHost host, string baseUri)
{
Fx.Assert(host != null, "WorkflowServiceHost parameter was null");
foreach (object service in this.services.Values)
{
host.WorkflowExtensions.Add(service);
ExternalDataExchangeService dataExchangeService = service as ExternalDataExchangeService;
if (dataExchangeService != null)
{
dataExchangeService.SetEnqueueMessageWrapper(new WorkflowClientDeliverMessageWrapper(baseUri));
foreach (object innerService in dataExchangeService.GetAllServices())
{
host.WorkflowExtensions.Add(innerService);
}
}
}
}
}
}

View File

@@ -0,0 +1,33 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Configuration
{
using System.Configuration;
using System.Workflow.Runtime.Configuration;
using System.Diagnostics.CodeAnalysis;
// Legacy WF V1 configuration extension
[SuppressMessage("Configuration", "Configuration100")]
[SuppressMessage("Configuration", "Configuration101")]
[ConfigurationCollection(typeof(WorkflowRuntimeServiceElement))]
[Obsolete("The WF3 types are deprecated. Instead, please use the new WF4 types from System.Activities.*")]
public class ExtendedWorkflowRuntimeServiceElementCollection : WorkflowRuntimeServiceElementCollection
{
public ExtendedWorkflowRuntimeServiceElementCollection()
: base()
{
// empty
}
public void Remove(WorkflowRuntimeServiceElement serviceSettings)
{
base.BaseRemove(base.GetElementKey(serviceSettings));
}
public void Remove(string key)
{
base.BaseRemove(key);
}
}
}

View File

@@ -0,0 +1,161 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Configuration
{
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime;
using System.ServiceModel.Description;
using System.ServiceModel.Persistence;
using System.Workflow.Runtime;
using System.Xml;
[Obsolete("The WF3 types are deprecated. Instead, please use the new WF4 types from System.Activities.*")]
public class PersistenceProviderElement : BehaviorExtensionElement
{
const string persistenceOperationTimeoutParameter = "persistenceOperationTimeout";
const string typeParameter = "type";
int argumentsHash;
NameValueCollection persistenceProviderArguments;
public PersistenceProviderElement()
{
this.persistenceProviderArguments = new NameValueCollection();
this.argumentsHash = this.ComputeArgumentsHash();
}
// This property is not supposed to be exposed in config.
[SuppressMessage("Configuration", "Configuration102:ConfigurationPropertyAttributeRule")]
public override Type BehaviorType
{
get { return typeof(PersistenceProviderBehavior); }
}
[ConfigurationProperty(
persistenceOperationTimeoutParameter,
IsRequired = false,
DefaultValue = PersistenceProviderBehavior.DefaultPersistenceOperationTimeoutString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[PositiveTimeSpanValidator]
public TimeSpan PersistenceOperationTimeout
{
get { return (TimeSpan) base[persistenceOperationTimeoutParameter]; }
set { base[persistenceOperationTimeoutParameter] = value; }
}
[SuppressMessage("Configuration", "Configuration102:ConfigurationPropertyAttributeRule")]
public NameValueCollection PersistenceProviderArguments
{
get { return this.persistenceProviderArguments; }
}
[ConfigurationProperty(typeParameter, IsRequired = true)]
[StringValidator(MinLength = 0)]
public string Type
{
get { return (string) base[typeParameter]; }
set { base[typeParameter] = value; }
}
protected internal override object CreateBehavior()
{
Fx.Assert(this.PersistenceOperationTimeout > TimeSpan.Zero,
"This should have been guaranteed by the validator on the setter.");
PersistenceProviderFactory providerFactory;
Type providerType = System.Type.GetType((string) base[typeParameter]);
if (providerType == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(SR2.GetString(SR2.PersistenceProviderTypeNotFound)));
}
ConstructorInfo cInfo = providerType.GetConstructor(new Type[] { typeof(NameValueCollection) });
if (cInfo != null)
{
providerFactory = (PersistenceProviderFactory) cInfo.Invoke(new object[] { this.persistenceProviderArguments });
}
else
{
cInfo = providerType.GetConstructor(new Type[] { });
Fx.Assert(cInfo != null,
"The constructor should have been found - this should have been validated elsewhere.");
providerFactory = (PersistenceProviderFactory) cInfo.Invoke(null);
}
return new PersistenceProviderBehavior(providerFactory, this.PersistenceOperationTimeout);
}
protected override bool IsModified()
{
return base.IsModified() || this.argumentsHash != this.ComputeArgumentsHash();
}
protected override bool OnDeserializeUnrecognizedAttribute(string name, string value)
{
persistenceProviderArguments.Add(name, value);
return true;
}
protected override void PostDeserialize()
{
this.argumentsHash = this.ComputeArgumentsHash();
base.PostDeserialize();
}
protected override bool SerializeElement(XmlWriter writer, bool serializeCollectionKey)
{
bool result;
if (writer != null)
{
foreach (string key in this.persistenceProviderArguments.AllKeys)
{
writer.WriteAttributeString(key, this.persistenceProviderArguments[key]);
}
result = base.SerializeElement(writer, serializeCollectionKey);
result |= this.persistenceProviderArguments.Count > 0;
this.argumentsHash = this.ComputeArgumentsHash();
}
else
{
result = base.SerializeElement(writer, serializeCollectionKey);
}
return result;
}
protected override void Unmerge(ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
{
PersistenceProviderElement persistenceProviderElement = (PersistenceProviderElement) sourceElement;
this.persistenceProviderArguments = new NameValueCollection(persistenceProviderElement.persistenceProviderArguments);
this.argumentsHash = persistenceProviderElement.argumentsHash;
base.Unmerge(sourceElement, parentElement, saveMode);
}
int ComputeArgumentsHash()
{
int result = 0;
foreach (string key in this.persistenceProviderArguments.AllKeys)
{
result ^= key.GetHashCode() ^ this.persistenceProviderArguments[key].GetHashCode();
}
return result;
}
}
}

View File

@@ -0,0 +1,164 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Configuration
{
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel.Description;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Configuration;
[Obsolete("The WF3 types are deprecated. Instead, please use the new WF4 types from System.Activities.*")]
public class WorkflowRuntimeElement : BehaviorExtensionElement
{
const string cachedInstanceExpiration = "cachedInstanceExpiration";
const string commonParameters = "commonParameters";
const string enablePerfCounters = "enablePerformanceCounters";
const string name = "name";
const string services = "services";
const string validateOnCreate = "validateOnCreate";
ConfigurationPropertyCollection configProperties = null;
WorkflowRuntimeSection wrtSection = null;
public WorkflowRuntimeElement()
{
}
// This property is not supposed to be exposed in config.
[SuppressMessage("Configuration", "Configuration102:ConfigurationPropertyAttributeRule", MessageId = "System.ServiceModel.Configuration.WorkflowRuntimeElement.BehaviorType")]
public override Type BehaviorType
{
get
{
return typeof(WorkflowRuntimeBehavior);
}
}
[ConfigurationProperty(cachedInstanceExpiration, IsRequired = false, DefaultValue = WorkflowRuntimeBehavior.DefaultCachedInstanceExpirationString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[PositiveTimeSpanValidator]
public TimeSpan CachedInstanceExpiration
{
get
{
return (TimeSpan) base[cachedInstanceExpiration];
}
set
{
base[cachedInstanceExpiration] = value;
}
}
[ConfigurationProperty(commonParameters, DefaultValue = null)]
public NameValueConfigurationCollection CommonParameters
{
get
{
return (NameValueConfigurationCollection) base[commonParameters];
}
}
[ConfigurationProperty(enablePerfCounters, DefaultValue = true)]
public bool EnablePerformanceCounters
{
get
{
return (bool) base[enablePerfCounters];
}
set
{
base[enablePerfCounters] = value;
}
}
[ConfigurationProperty(name, DefaultValue = "")]
[StringValidator(MinLength = 0)]
public string Name
{
get
{
return (string) base[name];
}
set
{
base[name] = value;
}
}
[ConfigurationProperty(services, DefaultValue = null)]
public ExtendedWorkflowRuntimeServiceElementCollection Services
{
get
{
return (ExtendedWorkflowRuntimeServiceElementCollection) base[services];
}
}
[ConfigurationProperty(validateOnCreate, DefaultValue = WorkflowRuntimeBehavior.DefaultValidateOnCreate)]
public bool ValidateOnCreate
{
get
{
return (bool) base[validateOnCreate];
}
set
{
base[validateOnCreate] = value;
}
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.configProperties == null)
{
this.configProperties = new ConfigurationPropertyCollection();
configProperties.Add(new ConfigurationProperty(name, typeof(string), null));
configProperties.Add(new ConfigurationProperty(validateOnCreate, typeof(bool), true));
configProperties.Add(new ConfigurationProperty(enablePerfCounters, typeof(bool), true));
configProperties.Add(new ConfigurationProperty(services, typeof(ExtendedWorkflowRuntimeServiceElementCollection), null));
configProperties.Add(new ConfigurationProperty(commonParameters, typeof(NameValueConfigurationCollection), null));
configProperties.Add(new ConfigurationProperty(cachedInstanceExpiration, typeof(TimeSpan), WorkflowRuntimeBehavior.DefaultCachedInstanceExpiration));
}
return this.configProperties;
}
}
protected internal override object CreateBehavior()
{
return new WorkflowRuntimeBehavior(new WorkflowRuntime(CreateWorkflowRuntimeSection()), this.CachedInstanceExpiration, this.ValidateOnCreate);
}
WorkflowRuntimeSection CreateWorkflowRuntimeSection()
{
if (wrtSection == null)
{
wrtSection = new WorkflowRuntimeSection();
wrtSection.Name = this.Name;
wrtSection.ValidateOnCreate = false;
wrtSection.EnablePerformanceCounters = this.EnablePerformanceCounters;
foreach (WorkflowRuntimeServiceElement wrtSvcElement in this.Services)
{
wrtSection.Services.Add(wrtSvcElement);
}
foreach (NameValueConfigurationElement nameValueElement in this.CommonParameters)
{
wrtSection.CommonParameters.Add(nameValueElement);
}
}
return wrtSection;
}
}
}

View File

@@ -0,0 +1,75 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Description
{
using System.Collections.Generic;
using System.Workflow.ComponentModel;
using System.Workflow.Runtime;
class DescriptionCreator
{
WorkflowDefinitionContext workflowDefinitionContext;
public DescriptionCreator(WorkflowDefinitionContext workflowDefinitionContext)
{
if (workflowDefinitionContext == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workflowDefinitionContext");
}
this.workflowDefinitionContext = workflowDefinitionContext;
}
public ServiceDescription BuildServiceDescription(out IDictionary<string, ContractDescription> implementedContracts, out IList<Type> reflectedContracts)
{
ServiceDescriptionContext context = new ServiceDescriptionContext();
ServiceDescription description = new ServiceDescription();
ApplyBehaviors(description);
context.ServiceDescription = description;
Walker walker = new Walker(true);
walker.FoundActivity += delegate(Walker w, WalkerEventArgs args)
{
IServiceDescriptionBuilder activity = args.CurrentActivity as IServiceDescriptionBuilder;
if (activity == null)
{
return;
}
activity.BuildServiceDescription(context);
};
walker.Walk(this.workflowDefinitionContext.GetWorkflowDefinition());
if (context.Contracts == null || context.Contracts.Count == 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.NoContract)));
}
implementedContracts = context.Contracts;
reflectedContracts = context.ReflectedContracts;
return description;
}
void ApplyBehaviors(ServiceDescription serviceDescription)
{
WorkflowServiceBehavior wsb = new WorkflowServiceBehavior(workflowDefinitionContext);
serviceDescription.Behaviors.Add(wsb);
if (wsb.Name != null)
{
serviceDescription.Name = wsb.Name;
}
if (wsb.Namespace != null)
{
serviceDescription.Namespace = wsb.Namespace;
}
if (wsb.ConfigurationName != null)
{
serviceDescription.ConfigurationName = wsb.ConfigurationName;
}
}
}
}

View File

@@ -0,0 +1,149 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Description
{
using System;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Channels;
using System.ServiceModel.Administration;
[AttributeUsage(AttributeTargets.Method)]
[Obsolete("The WF3 types are deprecated. Instead, please use the new WF4 types from System.Activities.*")]
public sealed class DurableOperationAttribute : Attribute, IOperationBehavior, IWmiInstanceProvider
{
static DurableOperationAttribute defaultInstance = new DurableOperationAttribute();
bool canCreateInstance;
bool canCreateInstanceSetExplicitly;
bool completesInstance;
public DurableOperationAttribute()
{
this.completesInstance = false;
}
public bool CanCreateInstance
{
get
{
return this.canCreateInstance;
}
set
{
this.canCreateInstance = value;
this.canCreateInstanceSetExplicitly = true;
}
}
public bool CompletesInstance
{
get
{
return this.completesInstance;
}
set
{
this.completesInstance = value;
}
}
internal static DurableOperationAttribute DefaultInstance
{
get
{
return defaultInstance;
}
}
public void AddBindingParameters(
OperationDescription operationDescription,
BindingParameterCollection bindingParameters)
{
// empty
}
public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
{
// empty
}
public void ApplyDispatchBehavior(
OperationDescription operationDescription,
DispatchOperation dispatchOperation)
{
if (dispatchOperation == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dispatchOperation");
}
if (dispatchOperation.Invoker == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(
SR2.GetString(
SR2.ExistingIOperationInvokerRequired,
typeof(DurableOperationAttribute).Name)));
}
if (operationDescription == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationDescription");
}
if (operationDescription.DeclaringContract == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(
"operationDescription",
SR2.GetString(SR2.OperationDescriptionNeedsDeclaringContract));
}
bool canCreate = CanCreateInstanceForOperation(dispatchOperation.IsOneWay);
dispatchOperation.Invoker =
new ServiceOperationInvoker(
dispatchOperation.Invoker,
this.CompletesInstance,
canCreate,
operationDescription.DeclaringContract.SessionMode != SessionMode.NotAllowed);
}
void IWmiInstanceProvider.FillInstance(IWmiInstance wmiInstance)
{
wmiInstance.SetProperty("CanCreateInstance", this.CanCreateInstance);
wmiInstance.SetProperty("CompletesInstance", this.CompletesInstance);
}
string IWmiInstanceProvider.GetInstanceType()
{
return "DurableOperationAttribute";
}
public void Validate(OperationDescription operationDescription)
{
// empty
}
internal bool CanCreateInstanceForOperation(bool isOneWay)
{
bool canCreate = false;
if (this.canCreateInstanceSetExplicitly)
{
canCreate = this.canCreateInstance;
}
else
{
if (isOneWay)
{
canCreate = false;
}
else
{
canCreate = true;
}
}
return canCreate;
}
}
}

View File

@@ -0,0 +1,352 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Description
{
using System;
using System.Runtime;
using System.ServiceModel.Administration;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Persistence;
using System.Xml;
[AttributeUsage(AttributeTargets.Class)]
[Obsolete("The WF3 types are deprecated. Instead, please use the new WF4 types from System.Activities.*")]
public sealed class DurableServiceAttribute : Attribute, IServiceBehavior, IContextSessionProvider, IWmiInstanceProvider
{
static DurableOperationAttribute defaultDurableOperationBehavior = new DurableOperationAttribute();
bool saveStateInOperationTransaction;
UnknownExceptionAction unknownExceptionAction;
public DurableServiceAttribute()
{
this.unknownExceptionAction = UnknownExceptionAction.TerminateInstance;
}
public bool SaveStateInOperationTransaction
{
get { return this.saveStateInOperationTransaction; }
set { this.saveStateInOperationTransaction = value; }
}
public UnknownExceptionAction UnknownExceptionAction
{
get
{
return this.unknownExceptionAction;
}
set
{
if (!UnknownExceptionActionHelper.IsDefined(value))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value"));
}
this.unknownExceptionAction = value;
}
}
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
{
// empty
}
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
if (serviceDescription == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceDescription");
}
if (serviceHostBase == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceHostBase");
}
if (serviceDescription.Endpoints == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("serviceDescription", SR2.GetString(SR2.NoEndpoints));
}
PersistenceProviderBehavior providerBehavior = null;
if (serviceDescription.Behaviors != null)
{
providerBehavior = serviceDescription.Behaviors.Find<PersistenceProviderBehavior>();
}
if (providerBehavior == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(
SR2.GetString(
SR2.NonNullPersistenceProviderRequired,
typeof(PersistenceProvider).Name,
typeof(DurableServiceAttribute).Name)));
}
if (providerBehavior.PersistenceProviderFactory == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(
SR2.GetString(
SR2.NonNullPersistenceProviderRequired,
typeof(PersistenceProvider).Name,
typeof(DurableServiceAttribute).Name)));
}
providerBehavior.PersistenceProviderFactory.Open();
serviceHostBase.Closed += new EventHandler(
delegate(object sender, EventArgs args)
{
Fx.Assert(sender is ServiceHostBase, "The sender should be serviceHostBase.");
// We have no way of knowing whether the service host closed or aborted
// so we err on the side of abort for right now.
providerBehavior.PersistenceProviderFactory.Abort();
}
);
DurableInstanceContextProvider instanceContextProvider = new ServiceDurableInstanceContextProvider(
serviceHostBase,
false,
serviceDescription.ServiceType,
providerBehavior.PersistenceProviderFactory,
this.saveStateInOperationTransaction,
this.unknownExceptionAction,
new DurableRuntimeValidator(this.saveStateInOperationTransaction, this.unknownExceptionAction),
providerBehavior.PersistenceOperationTimeout);
DurableInstanceContextProvider singleCallInstanceContextProvider = null;
IInstanceProvider instanceProvider = new DurableInstanceProvider(instanceContextProvider);
bool includeExceptionDetails = false;
if (serviceDescription.Behaviors != null)
{
ServiceBehaviorAttribute serviceBehavior = serviceDescription.Behaviors.Find<ServiceBehaviorAttribute>();
if (serviceBehavior != null)
{
includeExceptionDetails |= serviceBehavior.IncludeExceptionDetailInFaults;
}
ServiceDebugBehavior serviceDebugBehavior = serviceDescription.Behaviors.Find<ServiceDebugBehavior>();
if (serviceDebugBehavior != null)
{
includeExceptionDetails |= serviceDebugBehavior.IncludeExceptionDetailInFaults;
}
}
IErrorHandler errorHandler = new ServiceErrorHandler(includeExceptionDetails);
foreach (ChannelDispatcherBase channelDispatcherBase in serviceHostBase.ChannelDispatchers)
{
ChannelDispatcher channelDispatcher = channelDispatcherBase as ChannelDispatcher;
if (channelDispatcher != null && channelDispatcher.HasApplicationEndpoints())
{
if (this.unknownExceptionAction == UnknownExceptionAction.AbortInstance)
{
channelDispatcher.ErrorHandlers.Add(errorHandler);
}
foreach (EndpointDispatcher endpointDispatcher in channelDispatcher.Endpoints)
{
if (endpointDispatcher.IsSystemEndpoint)
{
continue;
}
ServiceEndpoint serviceEndPoint = serviceDescription.Endpoints.Find(new XmlQualifiedName(endpointDispatcher.ContractName, endpointDispatcher.ContractNamespace));
if (serviceEndPoint != null)
{
if (serviceEndPoint.Contract.SessionMode != SessionMode.NotAllowed)
{
endpointDispatcher.DispatchRuntime.InstanceContextProvider = instanceContextProvider;
}
else
{
if (singleCallInstanceContextProvider == null)
{
singleCallInstanceContextProvider = new ServiceDurableInstanceContextProvider(
serviceHostBase,
true,
serviceDescription.ServiceType,
providerBehavior.PersistenceProviderFactory,
this.saveStateInOperationTransaction,
this.unknownExceptionAction,
new DurableRuntimeValidator(this.saveStateInOperationTransaction, this.unknownExceptionAction),
providerBehavior.PersistenceOperationTimeout);
}
endpointDispatcher.DispatchRuntime.InstanceContextProvider = singleCallInstanceContextProvider;
}
endpointDispatcher.DispatchRuntime.MessageInspectors.Add(new DurableMessageDispatchInspector(serviceEndPoint.Contract.SessionMode));
endpointDispatcher.DispatchRuntime.InstanceProvider = instanceProvider;
WorkflowServiceBehavior.SetContractFilterToIncludeAllOperations(endpointDispatcher, serviceEndPoint.Contract);
}
}
}
}
foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints)
{
if (!endpoint.InternalIsSystemEndpoint(serviceDescription))
{
foreach (OperationDescription opDescription in endpoint.Contract.Operations)
{
if (!opDescription.Behaviors.Contains(typeof(DurableOperationAttribute)))
{
opDescription.Behaviors.Add(DurableOperationAttribute.DefaultInstance);
}
}
}
}
}
void IWmiInstanceProvider.FillInstance(IWmiInstance wmiInstance)
{
wmiInstance.SetProperty("SaveStateInOperationTransaction", this.saveStateInOperationTransaction);
}
string IWmiInstanceProvider.GetInstanceType()
{
return "DurableServiceAttribute";
}
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
if (serviceDescription == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceDescription");
}
ContextBindingElement.ValidateContextBindingElementOnAllEndpointsWithSessionfulContract(serviceDescription, this);
if (serviceDescription.Behaviors != null)
{
ServiceBehaviorAttribute serviceBehavior = serviceDescription.Behaviors.Find<ServiceBehaviorAttribute>();
if (serviceBehavior != null)
{
if (serviceBehavior.InstanceContextMode != InstanceContextMode.PerSession)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(
SR2.GetString(SR2.InstanceContextModeMustBePerSession, serviceBehavior.InstanceContextMode)));
}
if (serviceBehavior.ConcurrencyMode == ConcurrencyMode.Multiple)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(
SR2.GetString(SR2.ConcurrencyMultipleNotSupported)));
}
if (serviceBehavior.ConcurrencyMode == ConcurrencyMode.Reentrant
&& this.UnknownExceptionAction == UnknownExceptionAction.AbortInstance)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(
SR2.GetString(SR2.ConcurrencyReentrantAndAbortNotSupported)));
}
}
}
bool foundSessionfulContract = false;
foreach (ServiceEndpoint serviceEndpoint in serviceDescription.Endpoints)
{
if (serviceEndpoint != null && !serviceEndpoint.InternalIsSystemEndpoint(serviceDescription))
{
if (serviceEndpoint.Contract.SessionMode != SessionMode.NotAllowed)
{
foundSessionfulContract = true;
}
foreach (OperationDescription operation in serviceEndpoint.Contract.Operations)
{
DurableOperationAttribute durableBehavior =
operation.Behaviors.Find<DurableOperationAttribute>();
if (durableBehavior == null)
{
durableBehavior = defaultDurableOperationBehavior;
}
if (serviceEndpoint.Contract.SessionMode == SessionMode.NotAllowed)
{
if (!durableBehavior.CanCreateInstanceForOperation(operation.IsOneWay))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(
SR2.GetString(
SR2.CanCreateInstanceMustBeTrue,
serviceEndpoint.Contract.Name,
operation.Name)));
}
}
else
{
if (operation.IsOneWay &&
durableBehavior.CanCreateInstanceForOperation(operation.IsOneWay))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(
SR2.GetString(
SR2.CanCreateInstanceMustBeTwoWay,
serviceEndpoint.Contract.Name,
serviceEndpoint.Contract.SessionMode,
operation.Name)));
}
}
if (this.saveStateInOperationTransaction)
{
bool hasTransaction = false;
OperationBehaviorAttribute operationBehavior = operation.Behaviors.Find<OperationBehaviorAttribute>();
if (operationBehavior != null)
{
if (operationBehavior.TransactionScopeRequired)
{
hasTransaction = true;
}
}
TransactionFlowAttribute transactionBehavior = operation.Behaviors.Find<TransactionFlowAttribute>();
if (transactionBehavior != null)
{
if (transactionBehavior.Transactions == TransactionFlowOption.Mandatory)
{
hasTransaction = true;
}
}
if (!hasTransaction)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(
SR2.GetString(
SR2.SaveStateInTransactionValidationFailed,
operation.Name,
serviceEndpoint.ListenUri)));
}
}
}
}
}
if (!foundSessionfulContract)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(
SR2.GetString(SR2.SessionfulContractNotFound)));
}
}
}
}

View File

@@ -0,0 +1,13 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Description
{
using System;
interface IServiceDescriptionBuilder
{
void BuildServiceDescription(ServiceDescriptionContext context);
}
}

View File

@@ -0,0 +1,94 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Description
{
using System;
using System.Globalization;
using System.ServiceModel.Administration;
using System.ServiceModel.Persistence;
[Obsolete("The WF3 types are deprecated. Instead, please use the new WF4 types from System.Activities.*")]
public class PersistenceProviderBehavior : IServiceBehavior, IWmiInstanceProvider
{
internal static readonly TimeSpan DefaultPersistenceOperationTimeout = TimeSpan.Parse(DefaultPersistenceOperationTimeoutString, CultureInfo.InvariantCulture);
// 30 seconds was chosen because it is the default timeout for SqlCommand
// (seemed like a reasonable reference point)
internal const string DefaultPersistenceOperationTimeoutString = "00:00:30";
TimeSpan persistenceOperationTimeout;
PersistenceProviderFactory persistenceProviderFactory;
public PersistenceProviderBehavior(PersistenceProviderFactory providerFactory)
: this(providerFactory, DefaultPersistenceOperationTimeout)
{
// empty
}
public PersistenceProviderBehavior(PersistenceProviderFactory providerFactory, TimeSpan persistenceOperationTimeout)
{
this.PersistenceProviderFactory = providerFactory;
this.PersistenceOperationTimeout = persistenceOperationTimeout;
}
public TimeSpan PersistenceOperationTimeout
{
get
{
return this.persistenceOperationTimeout;
}
set
{
if (value < TimeSpan.Zero)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new ArgumentOutOfRangeException(SR2.GetString(SR2.PersistenceOperationTimeoutOutOfRange)));
}
this.persistenceOperationTimeout = value;
}
}
public PersistenceProviderFactory PersistenceProviderFactory
{
get
{
return this.persistenceProviderFactory;
}
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
this.persistenceProviderFactory = value;
}
}
public virtual void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
{
// empty
}
public virtual void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
// empty
}
void IWmiInstanceProvider.FillInstance(IWmiInstance wmiInstance)
{
wmiInstance.SetProperty("PersistenceOperationTimeout", this.PersistenceOperationTimeout.ToString());
wmiInstance.SetProperty("PersistenceProviderFactoryType", this.PersistenceProviderFactory.GetType().FullName);
}
string IWmiInstanceProvider.GetInstanceType()
{
return "PersistenceProviderBehavior";
}
public virtual void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
// empty
}
}
}

View File

@@ -0,0 +1,62 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Description
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.ServiceModel;
class ServiceDescriptionContext
{
Dictionary<string, ContractDescription> contracts;
IList<Type> reflectedContracts;
ServiceDescription serviceDescription;
Dictionary<KeyValuePair<Type, string>, WorkflowOperationBehavior> workflowOperationBehaviors;
internal ServiceDescriptionContext()
{
this.contracts = new Dictionary<string, ContractDescription>();
this.reflectedContracts = new List<Type>();
this.workflowOperationBehaviors = new Dictionary<KeyValuePair<Type, string>, WorkflowOperationBehavior>();
}
public IDictionary<string, ContractDescription> Contracts
{
get
{
return this.contracts;
}
}
public IList<Type> ReflectedContracts
{
get
{
return this.reflectedContracts;
}
}
public ServiceDescription ServiceDescription
{
get
{
return this.serviceDescription;
}
set
{
this.serviceDescription = value;
}
}
internal IDictionary<KeyValuePair<Type, string>, WorkflowOperationBehavior> WorkflowOperationBehaviors
{
get
{
return this.workflowOperationBehaviors;
}
}
}
}

View File

@@ -0,0 +1,14 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Description
{
using System;
[Obsolete("The WF3 types are deprecated. Instead, please use the new WF4 types from System.Activities.*")]
public enum UnknownExceptionAction
{
TerminateInstance = 0,
AbortInstance
}
}

View File

@@ -0,0 +1,16 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Description
{
using System;
static class UnknownExceptionActionHelper
{
public static bool IsDefined(UnknownExceptionAction action)
{
return action == UnknownExceptionAction.AbortInstance ||
action == UnknownExceptionAction.TerminateInstance;
}
}
}

View File

@@ -0,0 +1,93 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Description
{
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Channels;
using System.ServiceModel.Administration;
class WorkflowOperationBehavior : IOperationBehavior, IWmiInstanceProvider
{
bool canCreateInstance = true;
ServiceAuthorizationManager serviceAuthorizationManager;
public bool CanCreateInstance
{
get
{
return this.canCreateInstance;
}
set
{
this.canCreateInstance = value;
}
}
public ServiceAuthorizationManager ServiceAuthorizationManager
{
get
{
return this.serviceAuthorizationManager;
}
set
{
this.serviceAuthorizationManager = value;
}
}
public void AddBindingParameters(OperationDescription description, BindingParameterCollection parameters)
{
}
public void ApplyClientBehavior(OperationDescription description, ClientOperation proxy)
{
}
public void ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
{
if (description == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description");
}
if (dispatch == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dispatch");
}
if (dispatch.Parent == null
|| dispatch.Parent.ChannelDispatcher == null
|| dispatch.Parent.ChannelDispatcher.Host == null
|| dispatch.Parent.ChannelDispatcher.Host.Description == null
|| dispatch.Parent.ChannelDispatcher.Host.Description.Behaviors == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.DispatchOperationInInvalidState)));
}
WorkflowRuntimeBehavior workflowRuntimeBehavior = dispatch.Parent.ChannelDispatcher.Host.Description.Behaviors.Find<WorkflowRuntimeBehavior>();
if (workflowRuntimeBehavior == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.NoWorkflowRuntimeBehavior)));
}
dispatch.Invoker = new WorkflowOperationInvoker(description, this, workflowRuntimeBehavior.WorkflowRuntime, dispatch.Parent);
}
void IWmiInstanceProvider.FillInstance(IWmiInstance wmiInstance)
{
wmiInstance.SetProperty("CanCreateInstance", this.CanCreateInstance);
}
string IWmiInstanceProvider.GetInstanceType()
{
return "WorkflowOperationBehavior";
}
public void Validate(OperationDescription description)
{
}
}
}

Some files were not shown because too many files have changed in this diff Show More