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,60 @@
// <copyright>
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
namespace System.ServiceModel.Activities
{
using System;
using System.Collections.Specialized;
using System.Configuration;
internal static class AppSettings
{
private static volatile bool settingsInitialized = false;
private static object appSettingsLock = new object();
// false [default] to NOT have InstanceKeys automatically disassociated by default, so that they stay around until the completion of the workflow.
// true to have InstanceKeys automatically dissociated by default. Doing this affects the extensibility point WorkflowInstance.OnDisassociateKeys.
// <add key="workflowServices:DefaultAutomaticInstanceKeyDisassociation" value="true"/>
//
// NOTE - There is a similar setting in System.Activities because the changes affected by this are in both assemblies.
private static bool defaultAutomaticInstanceKeyDisassociation;
internal static bool DefaultAutomaticInstanceKeyDisassociation
{
get
{
EnsureSettingsLoaded();
return defaultAutomaticInstanceKeyDisassociation;
}
}
private static void EnsureSettingsLoaded()
{
if (!settingsInitialized)
{
lock (appSettingsLock)
{
if (!settingsInitialized)
{
NameValueCollection settings = null;
try
{
settings = ConfigurationManager.AppSettings;
}
finally
{
if (settings == null || !bool.TryParse(settings["microsoft:WorkflowServices:DefaultAutomaticInstanceKeyDisassociation"], out defaultAutomaticInstanceKeyDisassociation))
{
defaultAutomaticInstanceKeyDisassociation = false;
}
settingsInitialized = true;
}
}
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities
{
using System.Globalization;
using System.Runtime;
using System.Xml.Linq;
static class BookmarkNameHelper
{
public static string CreateBookmarkName(string operationName, XName serviceContractName)
{
Fx.Assert(!string.IsNullOrEmpty(operationName), "OperationName cannot be null or empty");
return string.Format(CultureInfo.InvariantCulture, "{0}|{1}", operationName, serviceContractName);
}
}
}

View File

@@ -0,0 +1,20 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities
{
public sealed class CallbackCorrelationInitializer : CorrelationInitializer
{
public CallbackCorrelationInitializer()
: base()
{
}
internal override CorrelationInitializer CloneCore()
{
return new CallbackCorrelationInitializer();
}
}
}

View File

@@ -0,0 +1,32 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Activities
{
using System.Globalization;
using System.Runtime;
using System.ServiceModel;
using System.ServiceModel.Channels;
static class ChannelCacheDefaults
{
internal const string DefaultIdleTimeoutString = "00:02:00";
internal static TimeSpan DefaultIdleTimeout = TimeSpan.Parse(DefaultIdleTimeoutString, CultureInfo.InvariantCulture);
internal const string DefaultMaxItemsPerCacheString = "16";
internal static int DefaultMaxItemsPerCache = Int32.Parse(DefaultMaxItemsPerCacheString, CultureInfo.CurrentCulture);
internal const string DefaultLeaseTimeoutString = "00:10:00";
internal static TimeSpan DefaultLeaseTimeout = TimeSpan.Parse(DefaultLeaseTimeoutString, CultureInfo.InvariantCulture);
internal const string DefaultFactoryLeaseTimeoutString = "Infinite";
internal static TimeSpan DefaultFactoryLeaseTimeout = TimeSpan.MaxValue;
internal const string DefaultChannelLeaseTimeoutString = "00:05:00";
internal static TimeSpan DefaultChannelLeaseTimeout = TimeSpan.Parse(DefaultChannelLeaseTimeoutString, CultureInfo.InvariantCulture);
internal const bool DefaultAllowUnsafeSharing = false;
}
}

View File

@@ -0,0 +1,84 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Activities
{
using System.Runtime;
using System.ServiceModel;
using System.ServiceModel.Channels;
public class ChannelCacheSettings
{
TimeSpan idleTimeout;
TimeSpan leaseTimeout;
int maxItemsInCache;
internal static ChannelCacheSettings EmptyCacheSettings = new ChannelCacheSettings { MaxItemsInCache = 0 };
public ChannelCacheSettings()
{
this.idleTimeout = ChannelCacheDefaults.DefaultIdleTimeout;
this.leaseTimeout = ChannelCacheDefaults.DefaultLeaseTimeout;
this.maxItemsInCache = ChannelCacheDefaults.DefaultMaxItemsPerCache;
}
[Fx.Tag.KnownXamlExternal]
public TimeSpan IdleTimeout
{
get
{
return this.idleTimeout;
}
set
{
TimeoutHelper.ThrowIfNegativeArgument(value);
if (TimeoutHelper.IsTooLarge(value))
{
throw FxTrace.Exception.ArgumentOutOfRange("IdleTimeout", value, SR.ValueTooLarge("IdleTimeout"));
}
this.idleTimeout = value;
}
}
[Fx.Tag.KnownXamlExternal]
public TimeSpan LeaseTimeout
{
get
{
return leaseTimeout;
}
set
{
TimeoutHelper.ThrowIfNegativeArgument(value);
if (TimeoutHelper.IsTooLarge(value))
{
throw FxTrace.Exception.ArgumentOutOfRange("LeaseTimeout", value, SR.ValueTooLarge("LeaseTimeout"));
}
this.leaseTimeout = value;
}
}
public int MaxItemsInCache
{
get
{
return this.maxItemsInCache;
}
set
{
if (value < 0)
{
throw FxTrace.Exception.ArgumentOutOfRange("MaxItemsInCache", value, SR.ValueCannotBeNegative("MaxItemsInCache"));
}
this.maxItemsInCache = value;
}
}
}
}

View File

@@ -0,0 +1,65 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities
{
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
static class ClientOperationFormatterProvider
{
static DispatchRuntime dummyDispatchRuntime;
[SuppressMessage(FxCop.Category.Performance, FxCop.Rule.AvoidUncalledPrivateCode,
Justification = "The GetFormatterFromRuntime uses this.")]
static ClientRuntime DummyClientRuntime
{
get
{
return DummyDispatchRuntime.CallbackClientRuntime;
}
}
[SuppressMessage(FxCop.Category.Performance, FxCop.Rule.AvoidUncalledPrivateCode,
Justification = "The GetFormatterFromRuntime uses this.")]
static DispatchRuntime DummyDispatchRuntime
{
get
{
if (dummyDispatchRuntime == null)
{
EndpointDispatcher dispatcher = new EndpointDispatcher(new EndpointAddress("http://dummyuri/"), "dummyContract", "urn:dummyContractNs");
dummyDispatchRuntime = dispatcher.DispatchRuntime;
}
return dummyDispatchRuntime;
}
}
[SuppressMessage(FxCop.Category.Performance, FxCop.Rule.AvoidUncalledPrivateCode,
Justification = "The GetFormatterFromRuntime is used by ClientOperationFormatterHelper")]
internal static IClientMessageFormatter GetFormatterFromRuntime(OperationDescription operationDescription)
{
System.ServiceModel.Dispatcher.ClientOperation clientOperation = new System.ServiceModel.Dispatcher.ClientOperation(DummyClientRuntime, operationDescription.Name, operationDescription.Messages[0].Action);
// Default to DataContractSerializerOperationBehavior
if (operationDescription.Behaviors.Count == 0)
{
IOperationBehavior operationBehavior = new DataContractSerializerOperationBehavior(operationDescription);
operationBehavior.ApplyClientBehavior(operationDescription, clientOperation);
}
else
{
foreach (IOperationBehavior operationBehavior in operationDescription.Behaviors)
{
operationBehavior.ApplyClientBehavior(operationDescription, clientOperation);
}
}
return clientOperation.Formatter;
}
}
}

View File

@@ -0,0 +1,55 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System.Runtime;
using System.Configuration;
using System.ComponentModel;
using System.ServiceModel.Configuration;
using System.ServiceModel.Activities.Description;
public sealed class BufferedReceiveElement : BehaviorExtensionElement
{
ConfigurationPropertyCollection properties;
const string MaxPendingMessagesPerChannelString = "maxPendingMessagesPerChannel";
public BufferedReceiveElement()
{
}
[ConfigurationProperty(MaxPendingMessagesPerChannelString, DefaultValue = BufferedReceiveServiceBehavior.DefaultMaxPendingMessagesPerChannel)]
[TypeConverter(typeof(Int32Converter))]
[IntegerValidator(MinValue = 1, MaxValue = Int32.MaxValue)]
public int MaxPendingMessagesPerChannel
{
get { return (int)base[MaxPendingMessagesPerChannelString]; }
set { base[MaxPendingMessagesPerChannelString] = value; }
}
protected internal override object CreateBehavior()
{
return new BufferedReceiveServiceBehavior() { MaxPendingMessagesPerChannel = this.MaxPendingMessagesPerChannel };
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration102:ConfigurationPropertyAttributeRule", MessageId = "System.ServiceModel.Activities.Configuration.BufferedReceiveElement.BehaviorType", Justification = "Not a configurable property; a property that had to be overridden from abstract parent class")]
public override Type BehaviorType
{
get { return typeof(BufferedReceiveServiceBehavior); }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty(MaxPendingMessagesPerChannelString, typeof(Int32), BufferedReceiveServiceBehavior.DefaultMaxPendingMessagesPerChannel, new Int32Converter(), new IntegerValidator(1, Int32.MaxValue), ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}

View File

@@ -0,0 +1,68 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System.Runtime;
using System.Configuration;
using System.ComponentModel;
using System.Globalization;
using System.ServiceModel.Configuration;
using System.ServiceModel.Activities.Description;
public sealed class ChannelSettingsElement : ConfigurationElement
{
ConfigurationPropertyCollection properties;
public ChannelSettingsElement()
{
}
[ConfigurationProperty(ConfigurationStrings.IdleTimeout, DefaultValue = ChannelCacheDefaults.DefaultIdleTimeoutString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan IdleTimeout
{
get { return (TimeSpan)base[ConfigurationStrings.IdleTimeout]; }
set { base[ConfigurationStrings.IdleTimeout] = value; }
}
[ConfigurationProperty(ConfigurationStrings.LeaseTimeout, DefaultValue = ChannelCacheDefaults.DefaultChannelLeaseTimeoutString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan LeaseTimeout
{
get { return (TimeSpan)base[ConfigurationStrings.LeaseTimeout]; }
set { base[ConfigurationStrings.LeaseTimeout] = value; }
}
[ConfigurationProperty(ConfigurationStrings.MaxItemsInCache, DefaultValue = ChannelCacheDefaults.DefaultMaxItemsPerCacheString)]
[IntegerValidator(MinValue = 0)]
public int MaxItemsInCache
{
get { return (int)base[ConfigurationStrings.MaxItemsInCache]; }
set { base[ConfigurationStrings.MaxItemsInCache] = value; }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty(ConfigurationStrings.MaxItemsInCache, typeof(System.Int32), ChannelCacheDefaults.DefaultMaxItemsPerCache, null, new System.Configuration.IntegerValidator(1, 2147483647, false), System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty(ConfigurationStrings.IdleTimeout, typeof(System.TimeSpan), ChannelCacheDefaults.DefaultIdleTimeout, new System.ServiceModel.Configuration.TimeSpanOrInfiniteConverter(), new System.ServiceModel.Configuration.TimeSpanOrInfiniteValidator(System.TimeSpan.Parse("00:00:00", CultureInfo.InvariantCulture), System.TimeSpan.Parse("24.20:31:23.6470000", CultureInfo.InvariantCulture)), System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty(ConfigurationStrings.LeaseTimeout, typeof(System.TimeSpan), ChannelCacheDefaults.DefaultFactoryLeaseTimeoutString, new System.ServiceModel.Configuration.TimeSpanOrInfiniteConverter(), new System.ServiceModel.Configuration.TimeSpanOrInfiniteValidator(System.TimeSpan.Parse("00:00:00", CultureInfo.InvariantCulture), System.TimeSpan.Parse("24.20:31:23.6470000", CultureInfo.InvariantCulture)), System.Configuration.ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}

View File

@@ -0,0 +1,33 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System.Globalization;
static class ConfigurationStrings
{
static string GetSectionPath(string sectionName)
{
return string.Format(CultureInfo.InvariantCulture, @"{0}/{1}", ConfigurationStrings.SectionGroupName, sectionName);
}
static internal string WorkflowHostingOptionsSectionPath
{
get { return ConfigurationStrings.GetSectionPath(ConfigurationStrings.WorkflowHostingOptionsSectionName); }
}
public const string AllowUnsafeCaching = "allowUnsafeCaching";
public const string ChannelSettings = "channelSettings";
public const string FactorySettings = "factorySettings";
public const string IdleTimeout = "idleTimeout";
public const string LeaseTimeout = "leaseTimeout";
public const string MaxItemsInCache = "maxItemsInCache";
// Default Values
public const string TimeSpanZero = "00:00:00";
public const string SectionGroupName = "system.serviceModel.activities";
public const string WorkflowHostingOptionsSectionName = "workflowHostingOptions";
public const string OverrideSiteName = "overrideSiteName";
}
}

View File

@@ -0,0 +1,74 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System;
using System.Runtime;
using System.Configuration;
using System.ServiceModel.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.ServiceModel.Activities.Description;
using System.ServiceModel.Activities.Tracking.Configuration;
using SR2 = System.ServiceModel.Activities.SR;
public class EtwTrackingBehaviorElement : BehaviorExtensionElement
{
ConfigurationPropertyCollection properties;
const string profileNameParameter = "profileName";
public EtwTrackingBehaviorElement()
{
}
[SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationPropertyAttributeRule,
Justification = "This property is defined by the base class to determine the type of the behavior.")]
public override Type BehaviorType
{
get { return typeof(EtwTrackingBehavior); }
}
[ConfigurationProperty(profileNameParameter, DefaultValue = "", Options = ConfigurationPropertyOptions.IsKey)]
[StringValidator(MinLength = 0)]
[SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationValidatorAttributeRule,
MessageId = "System.ServiceModel.Activities.Configuration.EtwTrackingBehaviorElement.ProfileName",
Justification = "StringValidator validates minimal size")]
public string ProfileName
{
get
{
return (string)base[profileNameParameter];
}
set
{
base[profileNameParameter] = value;
}
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty(profileNameParameter, typeof(System.String), string.Empty, null, new System.Configuration.StringValidator(0, 2147483647, null), System.Configuration.ConfigurationPropertyOptions.IsKey));
this.properties = properties;
}
return this.properties;
}
}
protected internal override object CreateBehavior()
{
EtwTrackingBehavior trackingBehavior = new EtwTrackingBehavior
{
ProfileName = this.ProfileName
};
return trackingBehavior;
}
}
}

View File

@@ -0,0 +1,68 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System.Runtime;
using System.Configuration;
using System.ComponentModel;
using System.Globalization;
using System.ServiceModel.Configuration;
using System.ServiceModel.Activities.Description;
public sealed class FactorySettingsElement : ConfigurationElement
{
ConfigurationPropertyCollection properties;
public FactorySettingsElement()
{
}
[ConfigurationProperty(ConfigurationStrings.IdleTimeout, DefaultValue = ChannelCacheDefaults.DefaultIdleTimeoutString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan IdleTimeout
{
get { return (TimeSpan)base[ConfigurationStrings.IdleTimeout]; }
set { base[ConfigurationStrings.IdleTimeout] = value; }
}
[ConfigurationProperty(ConfigurationStrings.LeaseTimeout, DefaultValue = ChannelCacheDefaults.DefaultFactoryLeaseTimeoutString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan LeaseTimeout
{
get { return (TimeSpan)base[ConfigurationStrings.LeaseTimeout]; }
set { base[ConfigurationStrings.LeaseTimeout] = value; }
}
[ConfigurationProperty(ConfigurationStrings.MaxItemsInCache, DefaultValue = ChannelCacheDefaults.DefaultMaxItemsPerCacheString)]
[IntegerValidator(MinValue = 0)]
public int MaxItemsInCache
{
get { return (int)base[ConfigurationStrings.MaxItemsInCache]; }
set { base[ConfigurationStrings.MaxItemsInCache] = value; }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty(ConfigurationStrings.MaxItemsInCache, typeof(System.Int32), ChannelCacheDefaults.DefaultMaxItemsPerCache, null, new System.Configuration.IntegerValidator(1, 2147483647, false), System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty(ConfigurationStrings.IdleTimeout, typeof(System.TimeSpan), ChannelCacheDefaults.DefaultIdleTimeout, new System.ServiceModel.Configuration.TimeSpanOrInfiniteConverter(), new System.ServiceModel.Configuration.TimeSpanOrInfiniteValidator(System.TimeSpan.Parse("00:00:00", CultureInfo.InvariantCulture), System.TimeSpan.Parse("24.20:31:23.6470000", CultureInfo.InvariantCulture)), System.Configuration.ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty(ConfigurationStrings.LeaseTimeout, typeof(System.TimeSpan), ChannelCacheDefaults.DefaultChannelLeaseTimeoutString, new System.ServiceModel.Configuration.TimeSpanOrInfiniteConverter(), new System.ServiceModel.Configuration.TimeSpanOrInfiniteValidator(System.TimeSpan.Parse("00:00:00", CultureInfo.InvariantCulture), System.TimeSpan.Parse("24.20:31:23.6470000", CultureInfo.InvariantCulture)), System.Configuration.ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}

View File

@@ -0,0 +1,79 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System.ComponentModel;
using System.Configuration;
using System.Runtime;
using System.ServiceModel.Activities;
using System.ServiceModel.Activities.Description;
using System.ServiceModel.Configuration;
public sealed class SendMessageChannelCacheElement : BehaviorExtensionElement
{
ConfigurationPropertyCollection properties;
public SendMessageChannelCacheElement()
{
}
[ConfigurationProperty(ConfigurationStrings.AllowUnsafeCaching, DefaultValue = ChannelCacheDefaults.DefaultAllowUnsafeSharing)]
public bool AllowUnsafeCaching
{
get { return (bool)base[ConfigurationStrings.AllowUnsafeCaching]; }
set { base[ConfigurationStrings.AllowUnsafeCaching] = value; }
}
[ConfigurationProperty(ConfigurationStrings.FactorySettings)]
public FactorySettingsElement FactorySettings
{
get { return (FactorySettingsElement)base[ConfigurationStrings.FactorySettings]; }
}
[ConfigurationProperty(ConfigurationStrings.ChannelSettings)]
public ChannelSettingsElement ChannelSettings
{
get { return (ChannelSettingsElement)base[ConfigurationStrings.ChannelSettings]; }
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration102:ConfigurationPropertyAttributeRule", MessageId = "System.ServiceModel.Activities.Configuration.SendMessageChannelCacheElement.BehaviorType", Justification = "Not a configurable property; a property that had to be overridden from abstract parent class")]
public override Type BehaviorType
{
get { return typeof(SendMessageChannelCacheBehavior); }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty(ConfigurationStrings.AllowUnsafeCaching, typeof(bool), ChannelCacheDefaults.DefaultAllowUnsafeSharing));
properties.Add(new ConfigurationProperty(ConfigurationStrings.FactorySettings, typeof(FactorySettingsElement)));
properties.Add(new ConfigurationProperty(ConfigurationStrings.ChannelSettings, typeof(ChannelSettingsElement)));
this.properties = properties;
}
return this.properties;
}
}
protected internal override object CreateBehavior()
{
return new SendMessageChannelCacheBehavior()
{
AllowUnsafeCaching = this.AllowUnsafeCaching,
FactorySettings = new ChannelCacheSettings { IdleTimeout = FactorySettings.IdleTimeout, LeaseTimeout = FactorySettings.LeaseTimeout, MaxItemsInCache = FactorySettings.MaxItemsInCache },
ChannelSettings = new ChannelCacheSettings { IdleTimeout = ChannelSettings.IdleTimeout, LeaseTimeout = ChannelSettings.LeaseTimeout, MaxItemsInCache = ChannelSettings.MaxItemsInCache }
};
}
}
}

View File

@@ -0,0 +1,41 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System;
using System.ComponentModel;
using System.Configuration;
using System.Reflection;
using System.ServiceModel.Channels;
using System.ServiceModel.Diagnostics.Application;
internal class ServiceModelActivitiesEnumValidator : ConfigurationValidatorBase
{
Type enumHelperType;
MethodInfo isDefined;
public ServiceModelActivitiesEnumValidator(Type enumHelperType)
{
this.enumHelperType = enumHelperType;
this.isDefined = this.enumHelperType.GetMethod("IsDefined", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
}
public override bool CanValidate(Type type)
{
return (this.isDefined != null);
}
public override void Validate(object value)
{
bool retVal = (bool)this.isDefined.Invoke(null, new object[] { value });
if (!retVal)
{
ParameterInfo[] isDefinedParameters = this.isDefined.GetParameters();
throw FxTrace.Exception.AsError(new InvalidEnumArgumentException("value", (int)value, isDefinedParameters[0].ParameterType));
}
}
}
}

View File

@@ -0,0 +1,31 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System;
using System.Configuration;
[AttributeUsage(AttributeTargets.Property)]
internal sealed class ServiceModelActivitiesEnumValidatorAttribute : ConfigurationValidatorAttribute
{
Type enumHelperType;
public ServiceModelActivitiesEnumValidatorAttribute(Type enumHelperType)
{
this.EnumHelperType = enumHelperType;
}
public Type EnumHelperType
{
get { return this.enumHelperType; }
set { this.enumHelperType = value; }
}
public override ConfigurationValidatorBase ValidatorInstance
{
get { return new ServiceModelActivitiesEnumValidator(enumHelperType); }
}
}
}

View File

@@ -0,0 +1,27 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System;
using System.Configuration;
public sealed class ServiceModelActivitiesSectionGroup : ConfigurationSectionGroup
{
public WorkflowHostingOptionsSection WorkflowHostingOptionsSection
{
get { return (WorkflowHostingOptionsSection)this.Sections[ConfigurationStrings.WorkflowHostingOptionsSectionName]; }
}
public static ServiceModelActivitiesSectionGroup GetSectionGroup(Configuration config)
{
if (config == null)
{
throw FxTrace.Exception.ArgumentNull("config");
}
return (ServiceModelActivitiesSectionGroup)config.SectionGroups[ConfigurationStrings.SectionGroupName];
}
}
}

View File

@@ -0,0 +1,184 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System.Activities.DurableInstancing;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.ServiceModel.Configuration;
using System.ServiceModel.Activities.Description;
using System.Runtime;
using System.Runtime.DurableInstancing;
[Fx.Tag.XamlVisible(false)]
public class SqlWorkflowInstanceStoreElement : BehaviorExtensionElement
{
const string connectionString = "connectionString";
const string connectionStringName = "connectionStringName";
const string defaultConnectionStringName = "DefaultSqlWorkflowInstanceStoreConnectionString";
const string hostLockRenewalPeriodParameter = "hostLockRenewalPeriod";
const string runnableInstancesDetectionPeriodParameter = "runnableInstancesDetectionPeriod";
const string instanceEncodingOption = "instanceEncodingOption";
const string instanceCompletionAction = "instanceCompletionAction";
const string instanceLockedExceptionAction = "instanceLockedExceptionAction";
const string maxConnectionRetries = "maxConnectionRetries";
public SqlWorkflowInstanceStoreElement()
{
}
[SuppressMessage(
FxCop.Category.Configuration,
FxCop.Rule.ConfigurationPropertyAttributeRule,
Justification = "This property only overrides the base property.")]
public override Type BehaviorType
{
get { return typeof(SqlWorkflowInstanceStoreBehavior); }
}
protected internal override object CreateBehavior()
{
bool useDefaultConnectionStringName = false;
if (string.IsNullOrEmpty(this.ConnectionString) &&
string.IsNullOrEmpty(this.ConnectionStringName))
{
useDefaultConnectionStringName = true;
}
if (!string.IsNullOrEmpty(this.ConnectionString) &&
!string.IsNullOrEmpty(this.ConnectionStringName))
{
throw FxTrace.Exception.AsError(new InstancePersistenceException(SR.CannotSpecifyBothConnectionStringAndName));
}
string connectionStringToUse;
if (!string.IsNullOrEmpty(this.ConnectionStringName) || useDefaultConnectionStringName)
{
string connectionStringNameToUse = useDefaultConnectionStringName ? defaultConnectionStringName : this.ConnectionStringName;
ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[connectionStringNameToUse];
if (settings == null)
{
if (useDefaultConnectionStringName)
{
throw FxTrace.Exception.AsError(new InstancePersistenceException(SR.MustSpecifyConnectionStringOrName));
}
throw FxTrace.Exception.Argument(connectionStringName, SR.ConnectionStringNameWrong(this.ConnectionStringName));
}
connectionStringToUse = settings.ConnectionString;
}
else
{
connectionStringToUse = this.ConnectionString;
}
SqlWorkflowInstanceStoreBehavior sqlWorkflowInstanceStoreBehavior = new SqlWorkflowInstanceStoreBehavior
{
ConnectionString = connectionStringToUse,
HostLockRenewalPeriod = this.HostLockRenewalPeriod,
InstanceEncodingOption = this.InstanceEncodingOption,
InstanceCompletionAction = this.InstanceCompletionAction,
InstanceLockedExceptionAction = this.InstanceLockedExceptionAction,
RunnableInstancesDetectionPeriod = this.RunnableInstancesDetectionPeriod,
MaxConnectionRetries = this.MaxConnectionRetries
};
return sqlWorkflowInstanceStoreBehavior;
}
[ConfigurationProperty(connectionString, IsRequired = false)]
[SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule",
Justification = "validated on CreateBehavior() when we try to retrive connection string")]
[StringValidator(MinLength = 0)]
public string ConnectionString
{
get { return (string)base[connectionString]; }
set { base[connectionString] = value; }
}
[ConfigurationProperty(connectionStringName, IsRequired = false)]
[SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule",
Justification = "validated on CreateBehavior() when we try to retrive connection string")]
[StringValidator(MinLength = 0)]
public string ConnectionStringName
{
get { return (string)base[connectionStringName]; }
set { base[connectionStringName] = value; }
}
[ConfigurationProperty(
hostLockRenewalPeriodParameter,
IsRequired = false,
DefaultValue = SqlWorkflowInstanceStoreBehavior.defaultHostRenewalString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[PositiveTimeSpanValidator]
public TimeSpan HostLockRenewalPeriod
{
get { return (TimeSpan)base[hostLockRenewalPeriodParameter]; }
set { base[hostLockRenewalPeriodParameter] = value; }
}
[ConfigurationProperty(
runnableInstancesDetectionPeriodParameter,
IsRequired = false,
DefaultValue = SqlWorkflowInstanceStoreBehavior.defaultRunnableInstancesDetectionPeriodString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[PositiveTimeSpanValidator]
public TimeSpan RunnableInstancesDetectionPeriod
{
get { return (TimeSpan)base[runnableInstancesDetectionPeriodParameter]; }
set { base[runnableInstancesDetectionPeriodParameter] = value; }
}
[ConfigurationProperty(
instanceEncodingOption,
IsRequired = false,
DefaultValue = SqlWorkflowInstanceStoreBehavior.defaultEncodingOption)]
[SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule")]
public InstanceEncodingOption InstanceEncodingOption
{
get { return (InstanceEncodingOption)base[instanceEncodingOption]; }
set { base[instanceEncodingOption] = value; }
}
[ConfigurationProperty(
instanceCompletionAction,
IsRequired = false,
DefaultValue = SqlWorkflowInstanceStoreBehavior.defaultInstanceCompletionAction)]
[SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule")]
public InstanceCompletionAction InstanceCompletionAction
{
get { return (InstanceCompletionAction)base[instanceCompletionAction]; }
set { base[instanceCompletionAction] = value; }
}
[ConfigurationProperty(
instanceLockedExceptionAction,
IsRequired = false,
DefaultValue = SqlWorkflowInstanceStoreBehavior.defaultInstanceLockedExceptionAction)]
[SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule")]
public InstanceLockedExceptionAction InstanceLockedExceptionAction
{
get { return (InstanceLockedExceptionAction)base[instanceLockedExceptionAction]; }
set { base[instanceLockedExceptionAction] = value; }
}
[ConfigurationProperty(
maxConnectionRetries,
IsRequired = false,
DefaultValue = SqlWorkflowInstanceStoreBehavior.defaultMaximumRetries)]
[IntegerValidator(MinValue = 0)]
[SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule")]
public int MaxConnectionRetries
{
get { return (int)base[maxConnectionRetries]; }
set { base[maxConnectionRetries] = value; }
}
}
}

View File

@@ -0,0 +1,13 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System.ServiceModel.Configuration;
public class WorkflowControlEndpointCollectionElement : StandardEndpointCollectionElement<WorkflowControlEndpoint, WorkflowControlEndpointElement>
{
}
}

View File

@@ -0,0 +1,186 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System;
using System.ServiceModel.Activities;
using System.ServiceModel.Description;
using System.Diagnostics.CodeAnalysis;
using System.Runtime;
using System.Configuration;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
public class WorkflowControlEndpointElement : StandardEndpointElement
{
ConfigurationPropertyCollection properties;
bool shouldLetConfigLoaderOverwriteAddress;
protected internal override Type EndpointType
{
get { return typeof(WorkflowControlEndpoint); }
}
[SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationValidatorAttributeRule,
Justification = "Value will be validated when converted into a Uri.")]
[ConfigurationProperty(System.ServiceModel.Configuration.ConfigurationStrings.Address, DefaultValue = "")]
public Uri Address
{
get { return (Uri)base[System.ServiceModel.Configuration.ConfigurationStrings.Address]; }
set { base[System.ServiceModel.Configuration.ConfigurationStrings.Address] = value; }
}
[ConfigurationProperty(System.ServiceModel.Configuration.ConfigurationStrings.Binding, DefaultValue = "")]
[StringValidator(MinLength = 0)]
public string Binding
{
get { return (string)base[System.ServiceModel.Configuration.ConfigurationStrings.Binding]; }
set
{
if (string.IsNullOrEmpty(value))
{
value = string.Empty;
}
base[System.ServiceModel.Configuration.ConfigurationStrings.Binding] = value;
}
}
[ConfigurationProperty(System.ServiceModel.Configuration.ConfigurationStrings.BindingConfiguration, DefaultValue = "")]
[StringValidator(MinLength = 0)]
public string BindingConfiguration
{
get { return (string)base[System.ServiceModel.Configuration.ConfigurationStrings.BindingConfiguration]; }
set
{
if (string.IsNullOrEmpty(value))
{
value = string.Empty;
}
base[System.ServiceModel.Configuration.ConfigurationStrings.BindingConfiguration] = value;
}
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = base.Properties;
properties.Add(
new ConfigurationProperty(
System.ServiceModel.Configuration.ConfigurationStrings.Binding,
typeof(string),
string.Empty,
null,
new StringValidator(0, 2147483647, null),
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
System.ServiceModel.Configuration.ConfigurationStrings.BindingConfiguration,
typeof(string),
string.Empty,
null,
new StringValidator(0, 2147483647, null),
ConfigurationPropertyOptions.None));
properties.Add(
new ConfigurationProperty(
System.ServiceModel.Configuration.ConfigurationStrings.Address,
typeof(Uri),
string.Empty,
null,
null,
ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
protected internal override ServiceEndpoint CreateServiceEndpoint(ContractDescription contractDescription)
{
WorkflowControlEndpoint result = new WorkflowControlEndpoint();
if (!string.IsNullOrEmpty(this.Binding))
{
Binding binding = ConfigLoader.LookupBinding(this.Binding, this.BindingConfiguration);
// we need to add validation here
if (binding == null)
{
throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR.FailedToLoadBindingInControlEndpoint(this.Binding, this.BindingConfiguration, this.Name)));
}
result.Binding = binding;
}
// This is only for client side
if (this.shouldLetConfigLoaderOverwriteAddress)
{
// ConfigLoader will check for null and overwrite it with the address from ChannelEndpointElement
result.Address = null;
}
return result;
}
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ChannelEndpointElement channelEndpointElement)
{
}
protected override void OnApplyConfiguration(ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement)
{
}
protected override void OnInitializeAndValidate(ServiceEndpointElement serviceEndpointElement)
{
// Override serviceEndpointElement.Address with this.Address when serviceEndpointElement.Address == null.
// This condition (serviceEndpointElement.Address == null) should only be true when used with the SqlWorkflowInstanceStoreBehavior.
// Setting the address here so that ConfigLoader is able to set the EndpointAddress correctly, especially when this.Address is
// a relative address and can only be made absolute using the baseAddresses configured on the serviceHost.
// Server side address inference goes by the following order:
// 1. ServiceEndpointElement.Address if it is not-null and non-default
// 2. WorkflowControlEndpointElement.Address
// 3. Host base address
if (serviceEndpointElement.Address == null ||
(!HasAddressSetByUser(serviceEndpointElement) && HasAddressSetByUser(this)))
{
serviceEndpointElement.Address = this.Address;
}
}
protected override void OnInitializeAndValidate(ChannelEndpointElement channelEndpointElement)
{
// Client side address inference goes by the following order:
// 1. ChannelEndpointElement.Address
// 2. WorkflowControlEndpointElement.Address
// 3. Default address from WorkflowControlEndpoint
if (HasAddressSetByUser(channelEndpointElement))
{
this.shouldLetConfigLoaderOverwriteAddress = true;
}
else if (HasAddressSetByUser(this))
{
channelEndpointElement.Address = this.Address;
this.shouldLetConfigLoaderOverwriteAddress = true;
}
}
bool HasAddressSetByUser(ConfigurationElement configurationElement)
{
return configurationElement.ElementInformation.Properties[System.ServiceModel.Configuration.ConfigurationStrings.Address].ValueOrigin != PropertyValueOrigin.Default;
}
}
}

View File

@@ -0,0 +1,37 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Globalization;
public sealed class WorkflowHostingOptionsSection : ConfigurationSection
{
public WorkflowHostingOptionsSection() : base()
{
}
[ConfigurationProperty(ConfigurationStrings.OverrideSiteName, DefaultValue = "false")]
public bool OverrideSiteName
{
get { return (bool)base[ConfigurationStrings.OverrideSiteName]; }
set { base[ConfigurationStrings.OverrideSiteName] = value; }
}
internal static WorkflowHostingOptionsSection GetSection()
{
WorkflowHostingOptionsSection retval = (WorkflowHostingOptionsSection)ConfigurationManager.GetSection(ConfigurationStrings.WorkflowHostingOptionsSectionPath);
if (retval == null)
{
retval = new WorkflowHostingOptionsSection();
}
return retval;
}
}
}

View File

@@ -0,0 +1,74 @@
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
namespace System.ServiceModel.Activities.Configuration
{
using System.ComponentModel;
using System.Configuration;
using System.Globalization;
using System.Runtime;
using System.ServiceModel.Activities.Description;
using System.ServiceModel.Configuration;
public sealed class WorkflowIdleElement : BehaviorExtensionElement
{
ConfigurationPropertyCollection properties;
const string TimeToPersistString = "timeToPersist";
const string TimeToUnloadString = "timeToUnload";
public WorkflowIdleElement()
{
}
[ConfigurationProperty(TimeToPersistString, DefaultValue = WorkflowIdleBehavior.defaultTimeToPersistString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan TimeToPersist
{
get { return (TimeSpan)base[TimeToPersistString]; }
set { base[TimeToPersistString] = value; }
}
[ConfigurationProperty(TimeToUnloadString, DefaultValue = WorkflowIdleBehavior.defaultTimeToUnloadString)]
[TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
[ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
public TimeSpan TimeToUnload
{
get { return (TimeSpan)base[TimeToUnloadString]; }
set { base[TimeToUnloadString] = value; }
}
protected internal override object CreateBehavior()
{
return new WorkflowIdleBehavior()
{ TimeToPersist = this.TimeToPersist, TimeToUnload = this.TimeToUnload };
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration102:ConfigurationPropertyAttributeRule", MessageId = "System.ServiceModel.Activities.Configuration.WorkflowIdleElement.BehaviorType", Justification = "Not a configurable property; a property that had to be overridden from abstract parent class")]
public override Type BehaviorType
{
get { return typeof(WorkflowIdleBehavior); }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
if (this.properties == null)
{
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
properties.Add(new ConfigurationProperty(TimeToPersistString, typeof(TimeSpan), TimeSpan.MaxValue, new TimeSpanOrInfiniteConverter(), new TimeSpanOrInfiniteValidator(TimeSpan.Zero, TimeSpan.MaxValue), ConfigurationPropertyOptions.None));
properties.Add(new ConfigurationProperty(TimeToUnloadString, typeof(TimeSpan), TimeSpan.Parse(WorkflowIdleBehavior.defaultTimeToUnloadString, CultureInfo.InvariantCulture), new TimeSpanOrInfiniteConverter(), new TimeSpanOrInfiniteValidator(TimeSpan.Zero, TimeSpan.MaxValue), ConfigurationPropertyOptions.None));
this.properties = properties;
}
return this.properties;
}
}
}
}

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