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,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user