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 @@
|
||||
000280f2ec63eb1649fb91da59f54b82bcd52643
|
||||
@@ -0,0 +1,50 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
// Code copied from WCF V1
|
||||
[module: SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", Scope = "member", Target = "System.ServiceModel.Diagnostics.ExceptionUtility+InternalException..ctor(System.Boolean)", MessageId = "System.SystemException.#ctor(System.String)")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.ServiceModel.Diagnostics.ExceptionUtility.ThrowHelperArgumentNull(System.String,System.String):System.ArgumentNullException")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.ServiceModel.Diagnostics.ExceptionUtility.ThrowHelperCallback(System.Exception):System.Exception")]
|
||||
[module: SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", Scope = "member", Target = "System.ServiceModel.Diagnostics.ExceptionUtility.ThrowHelperCallback(System.Exception):System.Exception", MessageId = "System.ServiceModel.Diagnostics.ExceptionUtility.ThrowHelperCallback(System.String,System.Exception)")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.ServiceModel.Diagnostics.ExceptionUtility.ThrowHelperFatal(System.String,System.Exception):System.Exception")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.ServiceModel.Diagnostics.ExceptionUtility.ThrowHelperWarning(System.Exception):System.Exception")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.ServiceModel.Diagnostics.ExceptionUtility.ThrowHelperArgument(System.String):System.ArgumentException")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.ServiceModel.Diagnostics.FatalException..ctor(System.String)")]
|
||||
|
||||
// Code copied from WF V1
|
||||
[module: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "System.Workflow.ComponentModel.Walker.WalkProperties(System.Workflow.ComponentModel.Activity,System.Object):System.Boolean")]
|
||||
[module: SuppressMessage("Reliability", "Reliability104:CaughtAndHandledExceptionsRule", Scope = "member", Target = "System.Workflow.ComponentModel.Walker.WalkProperties(System.Workflow.ComponentModel.Activity,System.Object):System.Boolean")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Workflow.ComponentModel.Walker..ctor(System.Boolean)")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Workflow.ComponentModel.Walker..ctor(System.Object)")]
|
||||
|
||||
|
||||
// Added by ramrajb, This warning is issued on the dialog resources of the System.Workflow.Activities dialgos, which hold types from System.WorkflowServices.dll , this warning complains that the assembly version does not match the Mscorlib assemblyversion of 4.0.0.0 , thats why this message is suppressed globally.
|
||||
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.ServiceContractDetailViewControl.resources", MessageId = ">>$this.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.ServiceContractViewControl.resources", MessageId = ">>backgroundPanel.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.ServiceContractViewControl.resources", MessageId = ">>$this.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.ServiceContractViewControl.resources", MessageId = ">>contractNameLabel.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.OperationPickerDialog.resources", MessageId = ">>footerPanel.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.OperationPickerDialog.resources", MessageId = ">>detailsViewPanel.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.OperationPickerDialog.resources", MessageId = ">>operationsPanel.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.OperationPickerDialog.resources", MessageId = ">>operationsListBox.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.OperationPickerDialog.resources", MessageId = ">>contentPanel.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.ServiceOperationDetailViewControl.resources", MessageId = ">>$this.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.ServiceOperationDetailViewControl.resources", MessageId = ">>editableLabelControl1.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.ServiceOperationViewControl.resources", MessageId = ">>backgroundPanel.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.ServiceOperationViewControl.resources", MessageId = ">>$this.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.ServiceOperationViewControl.resources", MessageId = ">>operationNameLabel.Type")]
|
||||
[module: SuppressMessage("Microsoft.Usage", "CA2228:DoNotShipUnreleasedResourceFormats", Scope = "resource", Target = "System.Workflow.Activities.Design.ReflectedServiceOperationDetailViewControl.resources", MessageId = ">>$this.Type")]
|
||||
|
||||
// Added by tvish for jself. These suppressions are for violations in red bits that are temporarily copied over.
|
||||
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Workflow.ComponentModel.WalkerEventArgs.get_CurrentValue():System.Object")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Workflow.ComponentModel.WalkerEventArgs.get_UserData():System.Object")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Workflow.ComponentModel.WalkerEventArgs.get_CurrentPropertyName():System.String")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Workflow.ComponentModel.WalkerEventArgs.get_CurrentPropertyOwner():System.Object")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Workflow.ComponentModel.WalkerEventArgs.get_CurrentProperty():System.Reflection.PropertyInfo")]
|
||||
[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Workflow.ComponentModel.WalkerEventArgs.set_Action(System.Workflow.ComponentModel.WalkerAction):System.Void")]
|
||||
[module: SuppressMessage("Reliability", "Reliability102:WrapExceptionsRule", Scope = "member", Target = "System.Workflow.Activities.ParameterInfoBasedPropertyDescriptor..ctor(System.Type,System.Reflection.ParameterInfo,System.Boolean,System.Attribute[])")]
|
||||
147
mcs/class/referencesource/System.WorkflowServices/ImageResources.Designer.cs
generated
Normal file
147
mcs/class/referencesource/System.WorkflowServices/ImageResources.Designer.cs
generated
Normal file
@@ -0,0 +1,147 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.312
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class ImageResources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal ImageResources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ImageResources", typeof(ImageResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Add {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Add", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap AddContract {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("AddContract", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap AddOperation {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("AddOperation", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Arrow {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Arrow", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Check {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Check", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Contract {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Contract", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Delete {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Delete", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Down {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Down", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Import {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Import", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap ImportedContract {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ImportedContract", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Operation {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Operation", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Up {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Up", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
105
mcs/class/referencesource/System.WorkflowServices/SR.cs
Normal file
105
mcs/class/referencesource/System.WorkflowServices/SR.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel
|
||||
{
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime;
|
||||
|
||||
[AttributeUsage(AttributeTargets.All)]
|
||||
sealed class SR2DescriptionAttribute : DescriptionAttribute
|
||||
{
|
||||
internal const string SendActivityDescription = "SendActivityDescription";
|
||||
internal const string ReceiveActivityDescription = "ReceiveActivityDescription";
|
||||
internal const string Receive_OperationValidation_Description = "Receive_OperationValidation_Description";
|
||||
internal const string Receive_CanCreateInstance_Description = "Receive_CanCreateInstance_Description";
|
||||
internal const string Receive_ContextToken_Description = "Receive_ContextToken_Description";
|
||||
internal const string Receive_FaultMessage_Description = "Receive_FaultMessage_Description";
|
||||
internal const string Receive_OperationInfo_Description = "Receive_OperationInfo_Description";
|
||||
internal const string Send_AfterResponse_Description = "Send_AfterResponse_Description";
|
||||
internal const string Send_BeforeSend_Description = "Send_BeforeSend_Description";
|
||||
internal const string Send_ChannelToken_Description = "Send_ChannelToken_Description";
|
||||
internal const string Send_CustomAddress_Description = "Send_CustomAddress_Description";
|
||||
internal const string Send_OperationInfo_Description = "Send_OperationInfo_Description";
|
||||
internal const string ContextToken_Name_Description = "ContextToken_Name_Description";
|
||||
internal const string ContextToken_OwnerActivityName_Description = "ContextToken_OwnerActivityName_Description";
|
||||
internal const string ChannelToken_EndpointName_Description = "ChannelToken_EndpointName_Description";
|
||||
internal const string ChannelToken_Name_Description = "ChannelToken_Name_Description";
|
||||
internal const string ChannelToken_OwnerActivityName_Description = "ChannelToken_OwnerActivityName_Description";
|
||||
|
||||
public SR2DescriptionAttribute(string description)
|
||||
{
|
||||
DescriptionValue = SR2.ResourceManager.GetString(description, SR2.Culture);
|
||||
}
|
||||
|
||||
public SR2DescriptionAttribute(string description, string resourceSet)
|
||||
{
|
||||
ResourceManager rm = new ResourceManager(resourceSet, Assembly.GetExecutingAssembly());
|
||||
DescriptionValue = rm.GetString(description);
|
||||
Fx.Assert(DescriptionValue != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", new object[] { description }));
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All)]
|
||||
sealed class SR2CategoryAttribute : CategoryAttribute
|
||||
{
|
||||
string resourceSet = String.Empty;
|
||||
internal const string Activity = "Activity";
|
||||
internal const string Standard = "Standard";
|
||||
internal const string Handlers = "Handlers";
|
||||
|
||||
public SR2CategoryAttribute(string category)
|
||||
: base(category)
|
||||
{
|
||||
}
|
||||
|
||||
public SR2CategoryAttribute(string category, string resourceSet)
|
||||
: base(category)
|
||||
{
|
||||
this.resourceSet = resourceSet;
|
||||
}
|
||||
|
||||
protected override string GetLocalizedString(string value)
|
||||
{
|
||||
if (this.resourceSet.Length > 0)
|
||||
{
|
||||
ResourceManager rm = new ResourceManager(resourceSet, Assembly.GetExecutingAssembly());
|
||||
String localizedString = rm.GetString(value);
|
||||
Fx.Assert(localizedString != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", new object[] { value }));
|
||||
return localizedString;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SR2.ResourceManager.GetString(value, SR2.Culture);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// This is a stub for auto-generated resource class, providing GetString function. Usage:
|
||||
///
|
||||
/// string s = SR2.GetString(SR2.MyIdenfitier);
|
||||
/// </summary>
|
||||
sealed partial class SR2
|
||||
{
|
||||
internal static string GetString(string name, params object[] args)
|
||||
{
|
||||
return GetString(resourceCulture, name, args);
|
||||
}
|
||||
internal static string GetString(CultureInfo culture, string name, params object[] args)
|
||||
{
|
||||
if (args != null && args.Length > 0)
|
||||
{
|
||||
return string.Format(culture, name, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace System.ServiceModel.Description
|
||||
{
|
||||
using System;
|
||||
|
||||
interface IServiceDescriptionBuilder
|
||||
{
|
||||
void BuildServiceDescription(ServiceDescriptionContext context);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user