Person IBusiness <Person> .Clone(CloneType operationType)
        {
            return((operationType == CloneType.Shallow) ? ((( ICloneable )this).Clone() as Person) :
                   null);

            { /* Replace null by an internal implementation for a deep clone operation. */ }
        }
Exemplo n.º 2
0
        // TODO: Issue #10353 - These variations need to be added once we have promotion support.
        /*
        [InlineData(CloneType.Normal, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.RepeatableRead, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.ReadCommitted, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.ReadUncommitted, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.Snapshot, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.Chaos, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.Unspecified, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.Serializable, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.RepeatableRead, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.ReadCommitted, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.ReadUncommitted, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.Snapshot, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.Chaos, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.Unspecified, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.Serializable, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.RepeatableRead, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.ReadCommitted, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.ReadUncommitted, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.Snapshot, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.Chaos, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.Unspecified, true, true, TransactionStatus.Committed)]
        */
        public void Run(CloneType cloneType, IsolationLevel isoLevel, bool forcePromote, bool completeClone, TransactionStatus expectedStatus )
        {
            TransactionOptions options = new TransactionOptions
            {
                IsolationLevel = isoLevel,
                // Shorten the delay before a timeout for blocking clones.
                Timeout = TimeSpan.FromSeconds(1)
            };

            CommittableTransaction tx = new CommittableTransaction(options);

            Transaction clone;
            switch (cloneType)
            {
                case CloneType.Normal:
                    {
                        clone = tx.Clone();
                        break;
                    }
                case CloneType.BlockingDependent:
                    {
                        clone = tx.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
                        break;
                    }
                case CloneType.RollbackDependent:
                    {
                        clone = tx.DependentClone(DependentCloneOption.RollbackIfNotComplete);
                        break;
                    }
                default:
                    {
                        throw new Exception("Unexpected CloneType - " + cloneType.ToString());
                    }
            }

            if (forcePromote)
            {
                HelperFunctions.PromoteTx(tx);
            }

            Assert.Equal(clone.IsolationLevel, tx.IsolationLevel);
            Assert.Equal(clone.TransactionInformation.Status, tx.TransactionInformation.Status);
            Assert.Equal(clone.TransactionInformation.LocalIdentifier, tx.TransactionInformation.LocalIdentifier);
            Assert.Equal(clone.TransactionInformation.DistributedIdentifier, tx.TransactionInformation.DistributedIdentifier);

            CommittableTransaction cloneCommittable = clone as CommittableTransaction;
            Assert.Null(cloneCommittable);

            try
            {
                tx.Commit();
            }
            catch (TransactionAbortedException)
            {
                Assert.Equal(expectedStatus, TransactionStatus.Aborted);
            }

            Assert.Equal(expectedStatus, tx.TransactionInformation.Status);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Applies this PrefabLinks change list to its GameObject. This will restore
        /// all deliberate modifications (made in the editor) of the GameObjects Properties
        /// after linking it to the Prefab.
        /// </summary>
        public void ApplyChanges()
        {
            if (this.changes == null || this.changes.Count == 0)
            {
                return;
            }

            for (int i = 0; i < this.changes.Count; i++)
            {
                GameObject targetObj = this.obj.GetChildAtIndexPath(this.changes[i].childIndex);
                object     target;
                if (this.changes[i].componentType != null)
                {
                    target = targetObj.GetComponent(this.changes[i].componentType);
                }
                else
                {
                    target = targetObj;
                }

                if (this.changes[i].prop != null && target != null)
                {
                    object applyVal = null;
                    try
                    {
                        CloneType cloneType = CloneProvider.GetCloneType(this.changes[i].prop.PropertyType);
                        if (cloneType.Type.IsValueType || cloneType.DefaultCloneBehavior != CloneBehavior.ChildObject)
                        {
                            applyVal = this.changes[i].val;
                        }
                        else
                        {
                            applyVal = this.changes[i].val.DeepClone();
                        }

                        this.changes[i].prop.SetValue(target, applyVal, null);
                    }
                    catch (Exception e)
                    {
                        Logs.Core.WriteError(
                            "Error applying PrefabLink changes in {0}, property {1}:\n{2}",
                            this.obj.FullName,
                            this.changes[i].prop.Name,
                            LogFormat.Exception(e));
                    }
                }
                else
                {
                    this.changes.RemoveAt(i);
                    i--;
                    continue;
                }
            }
        }
Exemplo n.º 4
0
        public CloneHelper(MainForm main, CloneType type)
        {
            InitializeComponent();
            _Main = main;
            _Type = type;

            Options.ApplyTheme(this);

            if (_Type == CloneType.Backup)
            {
                label1.Text = "Backing up, please wait";
            }
            if (_Type == CloneType.Restore)
            {
                label1.Text = "Restoring, please wait";
            }
        }
Exemplo n.º 5
0
        public T Clone(T source, CloneType cloneType)
        {
            switch (cloneType)
            {
            case CloneType.Deep:
                return(DeepClone(source));

            case CloneType.Shallow:
                return(ShallowClone(source));

            default:
                if (_defaultCloneOptions.DefaultCloneType == CloneType.Deep ||
                    _defaultCloneOptions.DefaultCloneType == CloneType.Shallow)
                {
                    return(Clone(source, _defaultCloneOptions.DefaultCloneType));
                }
                throw new NotSupportedException();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new change list entry.
        /// </summary>
        /// <param name="target">The target object in which the change has been made. Must be a GameObject or Component.</param>
        /// <param name="prop">The target objects <see cref="System.Reflection.PropertyInfo">Property</see> that has been changed.</param>
        public void PushChange(object target, PropertyInfo prop)
        {
            if (!prop.CanWrite || !prop.CanRead)
            {
                return;
            }
            object changeVal = prop.GetValue(target, null);

            // Clone the changelist entry value, if required
            if (changeVal != null)
            {
                CloneType cloneType = CloneProvider.GetCloneType(changeVal.GetType());
                if (!cloneType.Type.IsValueType && cloneType.DefaultCloneBehavior == CloneBehavior.ChildObject)
                {
                    changeVal = changeVal.DeepClone();
                }
            }

            this.PushChange(target, prop, changeVal);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Clone an object with one strategy (DeepClone or ShallowClone)
        /// </summary>
        /// <param name="obj">Object to perform cloning on.</param>
        /// <param name="cloneType">Type of cloning</param>
        /// <returns>Cloned object.</returns>
        /// <exception cref="InvalidOperationException">When a wrong enum for cloningtype is passed.</exception>
        public static T Clone(T obj, CloneType cloneType)
        {
            if (_globalCloneType != null)
            {
                _globalCloneType = cloneType;
            }
            switch (cloneType)
            {
            case CloneType.None:
                throw new InvalidOperationException("No need to call this method?");

            case CloneType.ShallowCloning:
                return(CloneObjectWithILShallow(obj));

            case CloneType.DeepCloning:
                return(CloneObjectWithILDeep(obj));

            default:
                break;
            }
            return(default(T));
        }
Exemplo n.º 8
0
        // TODO: Issue #10353 - These variations need to be added once we have promotion support.

        /*
         * [InlineData(CloneType.Normal, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.RepeatableRead, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.ReadCommitted, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.ReadUncommitted, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.Snapshot, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.Chaos, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.Unspecified, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.Serializable, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.RepeatableRead, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.ReadCommitted, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.ReadUncommitted, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.Snapshot, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.Chaos, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.Unspecified, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.Serializable, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.RepeatableRead, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.ReadCommitted, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.ReadUncommitted, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.Snapshot, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.Chaos, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.Unspecified, true, true, TransactionStatus.Committed)]
         */
        public void Run(CloneType cloneType, IsolationLevel isoLevel, bool forcePromote, bool completeClone, TransactionStatus expectedStatus)
        {
            TransactionOptions options = new TransactionOptions
            {
                IsolationLevel = isoLevel,
                // Shorten the delay before a timeout for blocking clones.
                Timeout = TimeSpan.FromSeconds(1)
            };

            // If we are dealing with a "normal" clone, we fully expect the transaction to commit successfully.
            // But a timeout of 1 seconds may not be enough for that to happen. So increase the timeout
            // for "normal" clones. This will not increase the test execution time in the "passing" scenario.
            if (cloneType == CloneType.Normal)
            {
                options.Timeout = TimeSpan.FromSeconds(10);
            }

            CommittableTransaction tx = new CommittableTransaction(options);

            Transaction clone;

            switch (cloneType)
            {
            case CloneType.Normal:
            {
                clone = tx.Clone();
                break;
            }

            case CloneType.BlockingDependent:
            {
                clone = tx.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
                break;
            }

            case CloneType.RollbackDependent:
            {
                clone = tx.DependentClone(DependentCloneOption.RollbackIfNotComplete);
                break;
            }

            default:
            {
                throw new Exception("Unexpected CloneType - " + cloneType.ToString());
            }
            }

            if (forcePromote)
            {
                HelperFunctions.PromoteTx(tx);
            }

            Assert.Equal(tx.IsolationLevel, clone.IsolationLevel);
            Assert.Equal(tx.TransactionInformation.Status, clone.TransactionInformation.Status);
            Assert.Equal(tx.TransactionInformation.LocalIdentifier, clone.TransactionInformation.LocalIdentifier);
            Assert.Equal(tx.TransactionInformation.DistributedIdentifier, clone.TransactionInformation.DistributedIdentifier);

            CommittableTransaction cloneCommittable = clone as CommittableTransaction;

            Assert.Null(cloneCommittable);

            try
            {
                tx.Commit();
            }
            catch (TransactionAbortedException ex)
            {
                Assert.Equal(expectedStatus, TransactionStatus.Aborted);
                switch (cloneType)
                {
                case CloneType.Normal:
                {
                    // We shouldn't be getting TransactionAbortedException for "normal" clones,
                    // so we have these two Asserts to possibly help determine what went wrong.
                    Assert.Null(ex.InnerException);
                    Assert.Equal("There shouldn't be any exception with this Message property", ex.Message);
                    break;
                }

                case CloneType.BlockingDependent:
                {
                    Assert.IsType <TimeoutException>(ex.InnerException);
                    break;
                }

                case CloneType.RollbackDependent:
                {
                    Assert.Null(ex.InnerException);
                    break;
                }

                default:
                {
                    throw new Exception("Unexpected CloneType - " + cloneType.ToString());
                }
                }
            }

            Assert.Equal(expectedStatus, tx.TransactionInformation.Status);
        }
Exemplo n.º 9
0
 static void clone(CloneType type, bit32 session)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 10
0
 public void RunOuterLoop(CloneType cloneType, IsolationLevel isoLevel, bool forcePromote, bool completeClone, TransactionStatus expectedStatus)
 {
     Run(cloneType, isoLevel, forcePromote, completeClone, expectedStatus);
 }
Exemplo n.º 11
0
 public CloneFieldInfo(FieldInfo field, CloneType cloneType)
 {
     Field     = field;
     CloneType = cloneType;
 }
Exemplo n.º 12
0
        // TODO: Issue #10353 - These variations need to be added once we have promotion support.

        /*
         * [InlineData(CloneType.Normal, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.RepeatableRead, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.ReadCommitted, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.ReadUncommitted, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.Snapshot, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.Chaos, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.Normal, IsolationLevel.Unspecified, false, false, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.Serializable, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.RepeatableRead, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.ReadCommitted, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.ReadUncommitted, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.Snapshot, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.Chaos, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.BlockingDependent, IsolationLevel.Unspecified, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.Serializable, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.RepeatableRead, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.ReadCommitted, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.ReadUncommitted, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.Snapshot, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.Chaos, true, true, TransactionStatus.Committed)]
         * [InlineData(CloneType.RollbackDependent, IsolationLevel.Unspecified, true, true, TransactionStatus.Committed)]
         */
        public void Run(CloneType cloneType, IsolationLevel isoLevel, bool forcePromote, bool completeClone, TransactionStatus expectedStatus)
        {
            TransactionOptions options = new TransactionOptions
            {
                IsolationLevel = isoLevel,
                // Shorten the delay before a timeout for blocking clones.
                Timeout = TimeSpan.FromSeconds(1)
            };

            CommittableTransaction tx = new CommittableTransaction(options);

            Transaction clone;

            switch (cloneType)
            {
            case CloneType.Normal:
            {
                clone = tx.Clone();
                break;
            }

            case CloneType.BlockingDependent:
            {
                clone = tx.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
                break;
            }

            case CloneType.RollbackDependent:
            {
                clone = tx.DependentClone(DependentCloneOption.RollbackIfNotComplete);
                break;
            }

            default:
            {
                throw new Exception("Unexpected CloneType - " + cloneType.ToString());
            }
            }

            if (forcePromote)
            {
                HelperFunctions.PromoteTx(tx);
            }

            Assert.Equal(clone.IsolationLevel, tx.IsolationLevel);
            Assert.Equal(clone.TransactionInformation.Status, tx.TransactionInformation.Status);
            Assert.Equal(clone.TransactionInformation.LocalIdentifier, tx.TransactionInformation.LocalIdentifier);
            Assert.Equal(clone.TransactionInformation.DistributedIdentifier, tx.TransactionInformation.DistributedIdentifier);

            CommittableTransaction cloneCommittable = clone as CommittableTransaction;

            Assert.Null(cloneCommittable);

            try
            {
                tx.Commit();
            }
            catch (TransactionAbortedException)
            {
                Assert.Equal(expectedStatus, TransactionStatus.Aborted);
            }

            Assert.Equal(expectedStatus, tx.TransactionInformation.Status);
        }
Exemplo n.º 13
0
        // TODO: Issue #10353 - These variations need to be added once we have promotion support.
        /*
        [InlineData(CloneType.Normal, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.RepeatableRead, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.ReadCommitted, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.ReadUncommitted, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.Snapshot, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.Chaos, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, IsolationLevel.Unspecified, false, false, TransactionStatus.Committed)]
        [InlineData(CloneType.Normal, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.Serializable, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.RepeatableRead, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.ReadCommitted, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.ReadUncommitted, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.Snapshot, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.Chaos, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.BlockingDependent, IsolationLevel.Unspecified, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.Serializable, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.RepeatableRead, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.ReadCommitted, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.ReadUncommitted, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.Snapshot, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.Chaos, true, true, TransactionStatus.Committed)]
        [InlineData(CloneType.RollbackDependent, IsolationLevel.Unspecified, true, true, TransactionStatus.Committed)]
        */
        public void Run(CloneType cloneType, IsolationLevel isoLevel, bool forcePromote, bool completeClone, TransactionStatus expectedStatus )
        {
            TransactionOptions options = new TransactionOptions
            {
                IsolationLevel = isoLevel,
                // Shorten the delay before a timeout for blocking clones.
                Timeout = TimeSpan.FromSeconds(1)
            };

            // If we are dealing with a "normal" clone, we fully expect the transaction to commit successfully.
            // But a timeout of 1 seconds may not be enough for that to happen. So increase the timeout
            // for "normal" clones. This will not increase the test execution time in the "passing" scenario.
            if (cloneType == CloneType.Normal)
            {
                options.Timeout = TimeSpan.FromSeconds(10);
            }

            CommittableTransaction tx = new CommittableTransaction(options);

            Transaction clone;
            switch (cloneType)
            {
                case CloneType.Normal:
                    {
                        clone = tx.Clone();
                        break;
                    }
                case CloneType.BlockingDependent:
                    {
                        clone = tx.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
                        break;
                    }
                case CloneType.RollbackDependent:
                    {
                        clone = tx.DependentClone(DependentCloneOption.RollbackIfNotComplete);
                        break;
                    }
                default:
                    {
                        throw new Exception("Unexpected CloneType - " + cloneType.ToString());
                    }
            }

            if (forcePromote)
            {
                HelperFunctions.PromoteTx(tx);
            }

            Assert.Equal(tx.IsolationLevel, clone.IsolationLevel);
            Assert.Equal(tx.TransactionInformation.Status, clone.TransactionInformation.Status);
            Assert.Equal(tx.TransactionInformation.LocalIdentifier, clone.TransactionInformation.LocalIdentifier);
            Assert.Equal(tx.TransactionInformation.DistributedIdentifier, clone.TransactionInformation.DistributedIdentifier);

            CommittableTransaction cloneCommittable = clone as CommittableTransaction;
            Assert.Null(cloneCommittable);

            try
            {
                tx.Commit();
            }
            catch (TransactionAbortedException ex)
            {
                Assert.Equal(expectedStatus, TransactionStatus.Aborted);
                switch (cloneType)
                {
                    case CloneType.Normal:
                        {
                            // We shouldn't be getting TransactionAbortedException for "normal" clones,
                            // so we have these two Asserts to possibly help determine what went wrong.
                            Assert.Null(ex.InnerException);
                            Assert.Equal("There shouldn't be any exception with this Message property", ex.Message);
                            break;
                        }
                    case CloneType.BlockingDependent:
                        {
                            Assert.IsType<TimeoutException>(ex.InnerException);
                            break;
                        }
                    case CloneType.RollbackDependent:
                        {
                            Assert.Null(ex.InnerException);
                            break;
                        }
                    default:
                        {
                            throw new Exception("Unexpected CloneType - " + cloneType.ToString());
                        }
                }
            }

            Assert.Equal(expectedStatus, tx.TransactionInformation.Status);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Execute remote command from client to queue managment using <see cref="QueueMessage"/>.
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        internal static NetStream ExecManager(QueueMessage message)
        {
            QueueState state = QueueState.Ok;

            try
            {
                NetStream stream = null;
                switch (message.Command)
                {
                case QueueManagerCmd.Reply:
                    return(QueueEntry.GetAckStream(QueueState.Ok, QueueManagerCmd.Reply, message.Key));

                case QueueManagerCmd.QueueProperties:
                    if (_Queue == null)
                    {
                        return(null);
                    }
                    return(message.AsyncTask(() => Queue.PerformanceCounter.GetPerformanceProperties(), message.Command));


                case QueueManagerCmd.CloneItems:
                    if (_Queue == null)
                    {
                        return(null);
                    }
                    var       args = message.GetArgs();
                    CloneType ct   = EnumExtension.Parse <CloneType>(args.Get <string>("value"), CloneType.All);
                    return(message.AsyncTask(() => Queue.CloneItems(ct), message.Command));

                case QueueManagerCmd.GetAllKeys:
                    if (_Queue == null)
                    {
                        return(null);
                    }
                    return(message.AsyncTask(() => Queue.GetAllKeys(), message.Command));

                case QueueManagerCmd.GetAllKeysIcons:
                    if (_Queue == null)
                    {
                        return(null);
                    }
                    return(message.AsyncTask(() => Queue.GetAllKeysIcons(), message.Command));

                case QueueManagerCmd.StateCounterQueue:
                    return(message.AsyncTask(() => QueueStateCounter(QueueAgentType.Queue), message.Command));

                case QueueManagerCmd.StateCounterSync:
                    return(message.AsyncTask(() => QueueStateCounter(QueueAgentType.SyncQueue), message.Command));

                case QueueManagerCmd.StateCounterSession:
                    return(message.AsyncTask(() => QueueStateCounter(QueueAgentType.SessionQueue), message.Command));

                case QueueManagerCmd.StateCounterDataQueue:
                    return(message.AsyncTask(() => QueueStateCounter(QueueAgentType.DataQueue), message.Command));

                case QueueManagerCmd.GetStateCounterReport:
                    return(message.AsyncTask(() => QueueStateCounter(), message.Command));

                case QueueManagerCmd.GetPerformanceReport:
                    return(message.AsyncTask(() => PerformanceReport(), message.Command));

                case QueueManagerCmd.GetAgentPerformanceReport:
                    QueueAgentType agentType = QueuePerformanceCounter.GetAgent(message.Key);
                    return(message.AsyncTask(() => PerformanceReport(agentType), message.Command));

                case QueueManagerCmd.ResetPerformanceCounter:
                    message.AsyncTask(() => ResetPerformanceCounter());
                    return(null);

                case QueueManagerCmd.GetAllDataKeys:
                    if (_DbQueue == null)
                    {
                        return(null);
                    }
                    return(message.AsyncTask(() => DbQueue.GetAllDataKeys(), message.Command));

                case QueueManagerCmd.GetAllSyncQueueKeys:
                    if (_SyncQueue == null)
                    {
                        return(null);
                    }
                    return(message.AsyncTask(() => SyncQueue.QueueKeys().ToArray(), message.Command));

                case QueueManagerCmd.QueueLog:
                    return(message.AsyncTask(() => QueueLogger.Logger.QueueLog(), message.Command));

                case QueueManagerCmd.GetAllSessionsKeys:
                    if (_Session == null)
                    {
                        return(null);
                    }
                    return(message.AsyncTask(() => Session.GetAllSessionsKeys(), message.Command));

                case QueueManagerCmd.GetAllSessionsStateKeys:
                    if (_Session == null)
                    {
                        return(null);
                    }
                    stream = new NetStream();
                    SessionState st = (SessionState)message.GetArgs().Get <int>("state");
                    return(message.AsyncTask(() => Session.GetAllSessionsStateKeys(st), message.Command));

                case QueueManagerCmd.GetSessionItemsKeys:
                    if (_Session == null)
                    {
                        return(null);
                    }
                    return(message.AsyncTask(() => Session.GetSessionsItemsKeys(message.Id), message.Command));

                //=== Queue api===================================================
                case QueueCmd.ViewItem:
                case QueueCmd.RemoveItem:
                    return(Queue.ExecRemote(message));

                //=== Data Queue api===================================================
                case DataQueueCmd.GetItemProperties:
                case DataQueueCmd.RemoveTable:
                //case DataQueueCmd.GetDataStatistic:
                case DataQueueCmd.GetDataTable:

                    return(DbQueue.ExecRemote(message));

                //=== Sync Queue api===================================================

                case SyncQueueCmd.RemoveSyncItem:
                case SyncQueueCmd.GetSyncItem:
                //case SyncQueueCmd.GetSyncStatistic:
                case SyncQueueCmd.GetItemsReport:

                    return(SyncQueue.ExecRemote(message));

                //=== Session Queue api===================================================

                case SessionCmd.RemoveSession:
                case SessionCmd.GetExistingSession:

                    return(Session.ExecRemote(message));
                }
            }
            catch (System.Runtime.Serialization.SerializationException se)
            {
                state = QueueState.SerializationError;
                QueueLogger.Logger.LogAction(QueueAction.QueueException, QueueActionState.Error, "ExecManager error: " + se.Message);
            }
            catch (Exception ex)
            {
                state = QueueState.UnexpectedError;
                QueueLogger.Logger.LogAction(QueueAction.QueueException, QueueActionState.Error, "ExecManager error: " + ex.Message);
            }

            return(QueueEntry.GetAckStream(state, message.Command)); //null;
        }
Exemplo n.º 15
0
        //

        public CloneableAttribute(CloneType type = CloneType.Deep)
        {
            this.type = type;
        }
Exemplo n.º 16
0
 public static void clone3 <T>(CloneType type, bit32 session, T data)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 17
0
 public CloneTypeAttribute(CloneType type)
 {
     Type = type;
 }