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,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//----------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//----------------------------------------------------------------
|
||||
|
||||
namespace System.Runtime.DurableInstancing
|
||||
{
|
||||
public enum InstanceKeyState
|
||||
{
|
||||
Unknown = 0,
|
||||
Associated,
|
||||
Completed,
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,75 @@
|
||||
//------------------------------------------------------------
|
||||
// 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 InstanceOwnerException : InstancePersistenceException
|
||||
{
|
||||
const string InstanceOwnerIdName = "instancePersistenceInstanceOwnerId";
|
||||
|
||||
public InstanceOwnerException()
|
||||
: base(SRCore.InstanceOwnerDefault)
|
||||
{
|
||||
}
|
||||
|
||||
public InstanceOwnerException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public InstanceOwnerException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public InstanceOwnerException(XName commandName, Guid instanceOwnerId)
|
||||
: this(commandName, instanceOwnerId, null)
|
||||
{
|
||||
}
|
||||
|
||||
public InstanceOwnerException(XName commandName, Guid instanceOwnerId, Exception innerException)
|
||||
: this(commandName, instanceOwnerId, ToMessage(instanceOwnerId), innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public InstanceOwnerException(XName commandName, Guid instanceOwnerId, string message, Exception innerException)
|
||||
: base(commandName, message, innerException)
|
||||
{
|
||||
InstanceOwnerId = instanceOwnerId;
|
||||
}
|
||||
|
||||
[SecurityCritical]
|
||||
protected InstanceOwnerException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
InstanceOwnerId = (Guid)info.GetValue(InstanceOwnerIdName, typeof(Guid));
|
||||
}
|
||||
|
||||
public Guid InstanceOwnerId { 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));
|
||||
}
|
||||
|
||||
static string ToMessage(Guid instanceOwnerId)
|
||||
{
|
||||
if (instanceOwnerId == Guid.Empty)
|
||||
{
|
||||
return SRCore.InstanceOwnerDefault;
|
||||
}
|
||||
return SRCore.InstanceOwnerSpecific(instanceOwnerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user