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,59 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System;
using System.Security.Permissions;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a9b8c4b5-b4a9-4800-8268-e8ec3b93d9ac")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
// Friend assemblies
[assembly: InternalsVisibleTo("System.Activities, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("System.Activities.DurableInstancing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("System.ServiceModel, PublicKey=00000000000000000400000000000000")]
[assembly: InternalsVisibleTo("System.ServiceModel.Activities, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("System.ServiceModel.Activation, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("System.ServiceModel.Routing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
//
[assembly: InternalsVisibleTo("CDF.CIT.Scenarios.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("Microsoft.CDF.Test.Persistence, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
// Need to provide InternalsVisibleTo System.Runtime.Serialization to allow serialization of internal DataContracts/DataMembers in partial trust.
[assembly: InternalsVisibleTo("System.Runtime.Serialization, PublicKey=00000000000000000400000000000000")]
// type forwards to System.ServiceModel.Internals.dll
[assembly: TypeForwardedTo(typeof(System.Runtime.ActionItem))]
[assembly: TypeForwardedTo(typeof(System.Runtime.AsyncResult))]
[assembly: TypeForwardedTo(typeof(System.Runtime.CompletedAsyncResult))]
[assembly: TypeForwardedTo(typeof(System.Runtime.Diagnostics.DiagnosticsEventProvider))]
[assembly: TypeForwardedTo(typeof(System.Runtime.Diagnostics.EtwProvider))]
[assembly: TypeForwardedTo(typeof(System.Runtime.Diagnostics.EventLogger))]
[assembly: TypeForwardedTo(typeof(System.Runtime.Diagnostics.StringTraceRecord))]
[assembly: TypeForwardedTo(typeof(System.Runtime.Diagnostics.TraceRecord))]
[assembly: TypeForwardedTo(typeof(System.Runtime.ExceptionTrace))]
[assembly: TypeForwardedTo(typeof(System.Runtime.Fx))]
[assembly: TypeForwardedTo(typeof(System.Runtime.IOThreadScheduler))]
[assembly: TypeForwardedTo(typeof(System.Runtime.PartialTrustHelpers))]
[assembly: TypeForwardedTo(typeof(System.Runtime.TraceEventLevel))]
[assembly: TypeForwardedTo(typeof(System.Runtime.TracePayload))]
[assembly: TypeForwardedTo(typeof(System.Runtime.TypeHelper))]
[assembly: TypeForwardedTo(typeof(System.Runtime.SynchronizedPool<>))]
[assembly: TypeForwardedTo(typeof(System.Runtime.BufferedOutputStream))]

View File

@@ -0,0 +1,31 @@
// <copyright>
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
namespace System.Runtime.DurableInstancing
{
using System;
internal class DisassociateInstanceKeysExtension
{
private bool automaticDisassociationEnabled;
internal DisassociateInstanceKeysExtension()
{
this.automaticDisassociationEnabled = false;
}
internal bool AutomaticDisassociationEnabled
{
get
{
return this.automaticDisassociationEnabled;
}
set
{
this.automaticDisassociationEnabled = value;
}
}
}
}

View File

@@ -0,0 +1,15 @@
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System;
using System.Xml.Linq;
//This sole purpose of this interface is to avoid adding S.SM.Activation as a friend of S.SM.Activities
interface IDurableInstancingOptions
{
void SetScopeName(XName scopeName);
}
}

View File

@@ -0,0 +1,59 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Security;
using System.Xml.Linq;
[Serializable]
public class InstanceCollisionException : InstancePersistenceCommandException
{
public InstanceCollisionException()
: this(SRCore.InstanceCollisionDefault, null)
{
}
public InstanceCollisionException(string message)
: this(message, null)
{
}
public InstanceCollisionException(string message, Exception innerException)
: base(message, innerException)
{
}
public InstanceCollisionException(XName commandName, Guid instanceId)
: this(commandName, instanceId, null)
{
}
public InstanceCollisionException(XName commandName, Guid instanceId, Exception innerException)
: this(commandName, instanceId, ToMessage(instanceId), innerException)
{
}
public InstanceCollisionException(XName commandName, Guid instanceId, string message, Exception innerException)
: base(commandName, instanceId, message, innerException)
{
}
[SecurityCritical]
protected InstanceCollisionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
static string ToMessage(Guid instanceId)
{
if (instanceId != Guid.Empty)
{
return SRCore.InstanceCollisionSpecific(instanceId);
}
return SRCore.InstanceCollisionDefault;
}
}
}

View File

@@ -0,0 +1,59 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System;
using System.Runtime.Serialization;
using System.Security;
using System.Xml.Linq;
[Serializable]
public class InstanceCompleteException : InstancePersistenceCommandException
{
public InstanceCompleteException()
: this(SRCore.InstanceCompleteDefault, null)
{
}
public InstanceCompleteException(string message)
: this(message, null)
{
}
public InstanceCompleteException(string message, Exception innerException)
: base(message, innerException)
{
}
public InstanceCompleteException(XName commandName, Guid instanceId)
: this(commandName, instanceId, null)
{
}
public InstanceCompleteException(XName commandName, Guid instanceId, Exception innerException)
: this(commandName, instanceId, ToMessage(instanceId), innerException)
{
}
public InstanceCompleteException(XName commandName, Guid instanceId, string message, Exception innerException)
: base(commandName, instanceId, message, innerException)
{
}
[SecurityCritical]
protected InstanceCompleteException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
static string ToMessage(Guid instanceId)
{
if (instanceId != Guid.Empty)
{
return SRCore.InstanceCompleteSpecific(instanceId);
}
return SRCore.InstanceCompleteDefault;
}
}
}

View File

@@ -0,0 +1,59 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Security;
using System.Xml.Linq;
[Serializable]
public class InstanceHandleConflictException : InstancePersistenceCommandException
{
public InstanceHandleConflictException()
: this(SRCore.InstanceHandleConflictDefault, null)
{
}
public InstanceHandleConflictException(string message)
: this(message, null)
{
}
public InstanceHandleConflictException(string message, Exception innerException)
: base(message, innerException)
{
}
public InstanceHandleConflictException(XName commandName, Guid instanceId)
: this(commandName, instanceId, null)
{
}
public InstanceHandleConflictException(XName commandName, Guid instanceId, Exception innerException)
: this(commandName, instanceId, ToMessage(instanceId), innerException)
{
}
public InstanceHandleConflictException(XName commandName, Guid instanceId, string message, Exception innerException)
: base(commandName, instanceId, message, innerException)
{
}
[SecurityCritical]
protected InstanceHandleConflictException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
static string ToMessage(Guid instanceId)
{
if (instanceId != Guid.Empty)
{
return SRCore.InstanceHandleConflictSpecific(instanceId);
}
return SRCore.InstanceHandleConflictDefault;
}
}
}

View File

@@ -0,0 +1,30 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
// This class serves as a reference back to an InstanceHandle from the perspective of an InstanceOwner for tracking lock binds in progress.
// It works in two modes, one as a pure cancelable handle reference (where cancelling means nulling out the reference) and the
// other as a queue position marker for determining when all of the in-progress requests at one point in time are all done. In the
// marker mode (InstanceOwner.LockResolutionMarker), it carries some additional context for maintaining the state of the
// InstancePersistenceContext.ResolveExistingLock operation.
class InstanceHandleReference
{
internal InstanceHandleReference(InstanceHandle instanceHandle)
{
Fx.Assert(instanceHandle != null, "Null instanceHandle provided to InstanceHandleReference.");
InstanceHandle = instanceHandle;
}
// This is set to null when the InstanceHandleReference is detached from the InstanceHandle - i.e. it is
// no longer in use, and exists just to make it possible to lazily drain out of the various queues.
internal InstanceHandle InstanceHandle { get; private set; }
internal void Cancel()
{
Fx.Assert(InstanceHandle != null, "InstanceHandleReference already cancelled.");
InstanceHandle = null;
}
}
}

View File

@@ -0,0 +1,152 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Xml.Linq;
[Fx.Tag.XamlVisible(false)]
[DataContract]
public class InstanceKey
{
static IDictionary<XName, InstanceValue> emptyMetadata = new ReadOnlyDictionaryInternal<XName, InstanceValue>(new Dictionary<XName, InstanceValue>(0));
static InstanceKey invalidKey = new InstanceKey();
bool invalid; // Comparisons to Guid.Empty are too slow.
IDictionary<XName, InstanceValue> metadata;
InstanceKey()
{
this.Value = Guid.Empty;
this.invalid = true;
}
public InstanceKey(Guid value)
: this(value, null)
{
}
public InstanceKey(Guid value, IDictionary<XName, InstanceValue> metadata)
{
if (value == Guid.Empty)
{
throw Fx.Exception.Argument("value", SRCore.InstanceKeyRequiresValidGuid);
}
this.Value = value;
if (metadata != null)
{
if (metadata.IsReadOnly)
{
this.Metadata = metadata;
}
else
{
Dictionary<XName, InstanceValue> copy = new Dictionary<XName, InstanceValue>(metadata);
this.Metadata = new ReadOnlyDictionaryInternal<XName, InstanceValue>(copy);
}
}
else
{
this.Metadata = emptyMetadata;
}
}
public bool IsValid
{
get
{
return !this.invalid;
}
}
public Guid Value
{
get;
private set;
}
public IDictionary<XName, InstanceValue> Metadata
{
get
{
// This can be true if the object was deserialized.
if (this.metadata == null)
{
this.metadata = emptyMetadata;
}
return this.metadata;
}
private set
{
this.metadata = value;
}
}
public static InstanceKey InvalidKey
{
get
{
return InstanceKey.invalidKey;
}
}
public override bool Equals(object obj)
{
return this.Value.Equals(((InstanceKey)obj).Value);
}
public override int GetHashCode()
{
return this.Value.GetHashCode();
}
[DataMember(Name = "Value")]
[SuppressMessage(FxCop.Category.Performance, FxCop.Rule.AvoidUncalledPrivateCode, Justification = "Called from Serialization")]
internal Guid SerializedValue
{
get
{
return this.Value;
}
set
{
if (value.CompareTo(Guid.Empty) == 0)
{
this.invalid = true;
}
else
{
this.Value = value;
}
}
}
[DataMember(Name = "Metadata", EmitDefaultValue = false)]
[SuppressMessage(FxCop.Category.Performance, FxCop.Rule.AvoidUncalledPrivateCode, Justification = "Called from Serialization")]
internal IDictionary<XName, InstanceValue> SerializedMetadata
{
get
{
if (this.Metadata.Count == 0)
{
return null;
}
else
{
return this.Metadata;
}
}
set
{
Fx.Assert(value != null, "A null value should not have been serialized because EmitDefaultValue is false");
this.Metadata = value;
}
}
}
}

View File

@@ -0,0 +1,87 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Security;
using System.Xml.Linq;
[Serializable]
public class InstanceKeyCollisionException : InstancePersistenceCommandException
{
const string ConflictingInstanceIdName = "instancePersistenceConflictingInstanceId";
const string InstanceKeyName = "instancePersistenceInstanceKey";
public InstanceKeyCollisionException()
: this(SRCore.KeyCollisionDefault, null)
{
}
public InstanceKeyCollisionException(string message)
: this(message, null)
{
}
public InstanceKeyCollisionException(string message, Exception innerException)
: base(message, innerException)
{
}
public InstanceKeyCollisionException(XName commandName, Guid instanceId, InstanceKey instanceKey, Guid conflictingInstanceId)
: this(commandName, instanceId, instanceKey, conflictingInstanceId, null)
{
}
public InstanceKeyCollisionException(XName commandName, Guid instanceId, InstanceKey instanceKey, Guid conflictingInstanceId, Exception innerException)
: this(commandName, instanceId, instanceKey, conflictingInstanceId, ToMessage(instanceId, instanceKey, conflictingInstanceId), innerException)
{
}
public InstanceKeyCollisionException(XName commandName, Guid instanceId, InstanceKey instanceKey, Guid conflictingInstanceId, string message, Exception innerException)
: base(commandName, instanceId, message, innerException)
{
ConflictingInstanceId = conflictingInstanceId;
InstanceKey = instanceKey;
}
[SecurityCritical]
protected InstanceKeyCollisionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
ConflictingInstanceId = (Guid)info.GetValue(ConflictingInstanceIdName, typeof(Guid));
Guid guid = (Guid)info.GetValue(InstanceKeyName, typeof(Guid));
InstanceKey = guid == Guid.Empty ? null : new InstanceKey(guid);
}
public Guid ConflictingInstanceId { get; private set; }
public InstanceKey InstanceKey { get; private set; }
[Fx.Tag.SecurityNote(Critical = "Overrides critical inherited method")]
[SecurityCritical]
[SuppressMessage(FxCop.Category.Security, FxCop.Rule.SecureGetObjectDataOverrides,
Justification = "Method is SecurityCritical")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(ConflictingInstanceIdName, ConflictingInstanceId, typeof(Guid));
info.AddValue(InstanceKeyName, (InstanceKey != null && InstanceKey.IsValid) ? InstanceKey.Value : Guid.Empty, typeof(Guid));
}
static string ToMessage(Guid instanceId, InstanceKey instanceKey, Guid conflictingInstanceId)
{
if (instanceKey != null && instanceKey.IsValid)
{
if (instanceId != Guid.Empty && conflictingInstanceId != Guid.Empty)
{
return SRCore.KeyCollisionSpecific(instanceId, instanceKey.Value, conflictingInstanceId);
}
return SRCore.KeyCollisionSpecificKeyOnly(instanceKey.Value);
}
return SRCore.KeyCollisionDefault;
}
}
}

View File

@@ -0,0 +1,77 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Security;
using System.Xml.Linq;
[Serializable]
public class InstanceKeyCompleteException : InstancePersistenceCommandException
{
const string InstanceKeyName = "instancePersistenceInstanceKey";
public InstanceKeyCompleteException()
: this(SRCore.KeyNotReadyDefault, null)
{
}
public InstanceKeyCompleteException(string message)
: this(message, null)
{
}
public InstanceKeyCompleteException(string message, Exception innerException)
: base(message, innerException)
{
}
public InstanceKeyCompleteException(XName commandName, InstanceKey instanceKey)
: this(commandName, instanceKey, null)
{
}
public InstanceKeyCompleteException(XName commandName, InstanceKey instanceKey, Exception innerException)
: this(commandName, Guid.Empty, instanceKey, ToMessage(instanceKey), innerException)
{
}
public InstanceKeyCompleteException(XName commandName, Guid instanceId, InstanceKey instanceKey, string message, Exception innerException)
: base(commandName, instanceId, message, innerException)
{
InstanceKey = instanceKey;
}
[SecurityCritical]
protected InstanceKeyCompleteException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Guid guid = (Guid)info.GetValue(InstanceKeyName, typeof(Guid));
InstanceKey = guid == Guid.Empty ? null : new InstanceKey(guid);
}
public InstanceKey InstanceKey { get; private set; }
[Fx.Tag.SecurityNote(Critical = "Overrides critical inherited method")]
[SecurityCritical]
[SuppressMessage(FxCop.Category.Security, FxCop.Rule.SecureGetObjectDataOverrides,
Justification = "Method is SecurityCritical")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(InstanceKeyName, (InstanceKey != null && InstanceKey.IsValid) ? InstanceKey.Value : Guid.Empty, typeof(Guid));
}
static string ToMessage(InstanceKey instanceKey)
{
if (instanceKey != null && instanceKey.IsValid)
{
return SRCore.KeyCompleteSpecific(instanceKey.Value);
}
return SRCore.KeyCompleteDefault;
}
}
}

View File

@@ -0,0 +1,77 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Security;
using System.Xml.Linq;
[Serializable]
public class InstanceKeyNotReadyException : InstancePersistenceCommandException
{
const string InstanceKeyName = "instancePersistenceInstanceKey";
public InstanceKeyNotReadyException()
: this(SRCore.KeyNotReadyDefault, null)
{
}
public InstanceKeyNotReadyException(string message)
: this(message, null)
{
}
public InstanceKeyNotReadyException(string message, Exception innerException)
: base(message, innerException)
{
}
public InstanceKeyNotReadyException(XName commandName, InstanceKey instanceKey)
: this(commandName, instanceKey, null)
{
}
public InstanceKeyNotReadyException(XName commandName, InstanceKey instanceKey, Exception innerException)
: this(commandName, Guid.Empty, instanceKey, ToMessage(instanceKey), innerException)
{
}
public InstanceKeyNotReadyException(XName commandName, Guid instanceId, InstanceKey instanceKey, string message, Exception innerException)
: base(commandName, instanceId, message, innerException)
{
InstanceKey = instanceKey;
}
[SecurityCritical]
protected InstanceKeyNotReadyException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Guid guid = (Guid)info.GetValue(InstanceKeyName, typeof(Guid));
InstanceKey = guid == Guid.Empty ? null : new InstanceKey(guid);
}
public InstanceKey InstanceKey { get; private set; }
[Fx.Tag.SecurityNote(Critical = "Overrides critical inherited method")]
[SecurityCritical]
[SuppressMessage(FxCop.Category.Security, FxCop.Rule.SecureGetObjectDataOverrides,
Justification = "Method is SecurityCritical")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(InstanceKeyName, (InstanceKey != null && InstanceKey.IsValid) ? InstanceKey.Value : Guid.Empty, typeof(Guid));
}
static string ToMessage(InstanceKey instanceKey)
{
if (instanceKey != null && instanceKey.IsValid)
{
return SRCore.KeyNotReadySpecific(instanceKey.Value);
}
return SRCore.KeyNotReadyDefault;
}
}
}

View File

@@ -0,0 +1,13 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
public enum InstanceKeyState
{
Unknown = 0,
Associated,
Completed,
}
}

View File

@@ -0,0 +1,72 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime;
using System.Xml.Linq;
[Fx.Tag.XamlVisible(false)]
public sealed class InstanceKeyView
{
static readonly ReadOnlyDictionaryInternal<XName, InstanceValue> emptyProperties = new ReadOnlyDictionaryInternal<XName, InstanceValue>(new Dictionary<XName, InstanceValue>(0));
IDictionary<XName, InstanceValue> metadata;
Dictionary<XName, InstanceValue> accumulatedMetadataWrites;
internal InstanceKeyView(Guid key)
{
InstanceKey = key;
InstanceKeyMetadataConsistency = InstanceValueConsistency.InDoubt | InstanceValueConsistency.Partial;
}
InstanceKeyView(InstanceKeyView source)
{
InstanceKey = source.InstanceKey;
InstanceKeyState = source.InstanceKeyState;
InstanceKeyMetadata = source.InstanceKeyMetadata;
InstanceKeyMetadataConsistency = source.InstanceKeyMetadataConsistency;
}
public Guid InstanceKey { get; private set; }
public InstanceKeyState InstanceKeyState { get; internal set; }
public InstanceValueConsistency InstanceKeyMetadataConsistency { get; internal set; }
public IDictionary<XName, InstanceValue> InstanceKeyMetadata
{
get
{
IDictionary<XName, InstanceValue> pendingWrites = this.accumulatedMetadataWrites;
this.accumulatedMetadataWrites = null;
this.metadata = pendingWrites.ReadOnlyMergeInto(this.metadata ?? InstanceKeyView.emptyProperties, true);
return this.metadata;
}
internal set
{
this.accumulatedMetadataWrites = null;
this.metadata = value;
}
}
internal Dictionary<XName, InstanceValue> AccumulatedMetadataWrites
{
get
{
if (this.accumulatedMetadataWrites == null)
{
this.accumulatedMetadataWrites = new Dictionary<XName, InstanceValue>();
}
return this.accumulatedMetadataWrites;
}
}
internal InstanceKeyView Clone()
{
return new InstanceKeyView(this);
}
}
}

View File

@@ -0,0 +1,59 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Security;
using System.Xml.Linq;
[Serializable]
public class InstanceLockLostException : InstancePersistenceCommandException
{
public InstanceLockLostException()
: this(SRCore.InstanceLockLostDefault, null)
{
}
public InstanceLockLostException(string message)
: this(message, null)
{
}
public InstanceLockLostException(string message, Exception innerException)
: base(message, innerException)
{
}
public InstanceLockLostException(XName commandName, Guid instanceId)
: this(commandName, instanceId, null)
{
}
public InstanceLockLostException(XName commandName, Guid instanceId, Exception innerException)
: this(commandName, instanceId, ToMessage(instanceId), innerException)
{
}
public InstanceLockLostException(XName commandName, Guid instanceId, string message, Exception innerException)
: base(commandName, instanceId, message, innerException)
{
}
[SecurityCritical]
protected InstanceLockLostException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
static string ToMessage(Guid instanceId)
{
if (instanceId != Guid.Empty)
{
return SRCore.InstanceLockLostSpecific(instanceId);
}
return SRCore.InstanceLockLostDefault;
}
}
}

View File

@@ -0,0 +1,39 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Xml.Linq;
[Fx.Tag.XamlVisible(false)]
public sealed class InstanceLockQueryResult : InstanceStoreQueryResult
{
static readonly ReadOnlyDictionaryInternal<Guid, Guid> EmptyQueryResult = new ReadOnlyDictionaryInternal<Guid, Guid>(new Dictionary<Guid, Guid>(0));
// Zero
public InstanceLockQueryResult()
{
InstanceOwnerIds = EmptyQueryResult;
}
// One
public InstanceLockQueryResult(Guid instanceId, Guid instanceOwnerId)
{
Dictionary<Guid, Guid> owners = new Dictionary<Guid, Guid>(1);
owners.Add(instanceId, instanceOwnerId);
InstanceOwnerIds = new ReadOnlyDictionaryInternal<Guid, Guid>(owners);
}
// N
public InstanceLockQueryResult(IDictionary<Guid, Guid> instanceOwnerIds)
{
Dictionary<Guid, Guid> copy = new Dictionary<Guid, Guid>(instanceOwnerIds);
InstanceOwnerIds = new ReadOnlyDictionaryInternal<Guid, Guid>(copy);
}
public IDictionary<Guid, Guid> InstanceOwnerIds { get; private set; }
}
}

View File

@@ -0,0 +1,116 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Security;
using System.Xml.Linq;
[Serializable]
public class InstanceLockedException : InstancePersistenceCommandException
{
const string InstanceOwnerIdName = "instancePersistenceInstanceOwnerId";
const string SerializableInstanceOwnerMetadataName = "instancePersistenceSerializableInstanceOwnerMetadata";
public InstanceLockedException()
: this(SRCore.CannotAcquireLockDefault, null)
{
}
public InstanceLockedException(string message)
: this(message, null)
{
}
public InstanceLockedException(string message, Exception innerException)
: base(message, innerException)
{
}
public InstanceLockedException(XName commandName, Guid instanceId)
: this(commandName, instanceId, null)
{
}
public InstanceLockedException(XName commandName, Guid instanceId, Exception innerException)
: this(commandName, instanceId, ToMessage(instanceId), innerException)
{
}
public InstanceLockedException(XName commandName, Guid instanceId, string message, Exception innerException)
: this(commandName, instanceId, Guid.Empty, null, message, innerException)
{
}
public InstanceLockedException(XName commandName, Guid instanceId, Guid instanceOwnerId, IDictionary<XName, object> serializableInstanceOwnerMetadata)
: this(commandName, instanceId, instanceOwnerId, serializableInstanceOwnerMetadata, null)
{
}
public InstanceLockedException(XName commandName, Guid instanceId, Guid instanceOwnerId, IDictionary<XName, object> serializableInstanceOwnerMetadata, Exception innerException)
: this(commandName, instanceId, instanceOwnerId, serializableInstanceOwnerMetadata, ToMessage(instanceId, instanceOwnerId), innerException)
{
}
// Copying the dictionary snapshots it and makes sure the IDictionary implementation is serializable.
public InstanceLockedException(XName commandName, Guid instanceId, Guid instanceOwnerId, IDictionary<XName, object> serializableInstanceOwnerMetadata, string message, Exception innerException)
: base(commandName, instanceId, message, innerException)
{
InstanceOwnerId = instanceOwnerId;
if (serializableInstanceOwnerMetadata != null)
{
Dictionary<XName, object> copy = new Dictionary<XName, object>(serializableInstanceOwnerMetadata);
SerializableInstanceOwnerMetadata = new ReadOnlyDictionaryInternal<XName, object>(copy);
}
}
[SecurityCritical]
protected InstanceLockedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
InstanceOwnerId = (Guid)info.GetValue(InstanceOwnerIdName, typeof(Guid));
SerializableInstanceOwnerMetadata = (ReadOnlyDictionaryInternal<XName, object>)info.GetValue(SerializableInstanceOwnerMetadataName, typeof(ReadOnlyDictionaryInternal<XName, object>));
}
public Guid InstanceOwnerId { get; private set; }
public IDictionary<XName, object> SerializableInstanceOwnerMetadata { get; private set; }
[Fx.Tag.SecurityNote(Critical = "Overrides critical inherited method")]
[SecurityCritical]
[SuppressMessage(FxCop.Category.Security, FxCop.Rule.SecureGetObjectDataOverrides,
Justification = "Method is SecurityCritical")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(InstanceOwnerIdName, InstanceOwnerId, typeof(Guid));
info.AddValue(SerializableInstanceOwnerMetadataName, SerializableInstanceOwnerMetadata, typeof(ReadOnlyDictionaryInternal<XName, object>));
}
static string ToMessage(Guid instanceId)
{
if (instanceId == Guid.Empty)
{
return SRCore.CannotAcquireLockDefault;
}
return SRCore.CannotAcquireLockSpecific(instanceId);
}
static string ToMessage(Guid instanceId, Guid instanceOwnerId)
{
if (instanceId == Guid.Empty)
{
return SRCore.CannotAcquireLockDefault;
}
if (instanceOwnerId == Guid.Empty)
{
return SRCore.CannotAcquireLockSpecific(instanceId);
}
return SRCore.CannotAcquireLockSpecificWithOwner(instanceId, instanceOwnerId);
}
}
}

View File

@@ -0,0 +1,39 @@
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System.Collections.Generic;
using System.Linq;
// InstanceStore owns the synchronization of this class.
class InstanceNormalEvent : InstancePersistenceEvent
{
HashSet<InstanceHandle> boundHandles = new HashSet<InstanceHandle>();
HashSet<InstanceHandle> pendingHandles = new HashSet<InstanceHandle>();
internal InstanceNormalEvent(InstancePersistenceEvent persistenceEvent)
: base(persistenceEvent.Name)
{
}
internal bool IsSignaled { get; set; }
internal HashSet<InstanceHandle> BoundHandles
{
get
{
return this.boundHandles;
}
}
internal HashSet<InstanceHandle> PendingHandles
{
get
{
return this.pendingHandles;
}
}
}
}

View File

@@ -0,0 +1,59 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Runtime.DurableInstancing
{
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Security;
using System.Xml.Linq;
[Serializable]
public class InstanceNotReadyException : InstancePersistenceCommandException
{
public InstanceNotReadyException()
: this(SRCore.InstanceNotReadyDefault, null)
{
}
public InstanceNotReadyException(string message)
: this(message, null)
{
}
public InstanceNotReadyException(string message, Exception innerException)
: base(message, innerException)
{
}
public InstanceNotReadyException(XName commandName, Guid instanceId)
: this(commandName, instanceId, null)
{
}
public InstanceNotReadyException(XName commandName, Guid instanceId, Exception innerException)
: this(commandName, instanceId, ToMessage(instanceId), innerException)
{
}
public InstanceNotReadyException(XName commandName, Guid instanceId, string message, Exception innerException)
: base(commandName, instanceId, message, innerException)
{
}
[SecurityCritical]
protected InstanceNotReadyException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
static string ToMessage(Guid instanceId)
{
if (instanceId != Guid.Empty)
{
return SRCore.InstanceNotReadySpecific(instanceId);
}
return SRCore.InstanceNotReadyDefault;
}
}
}

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