internal virtual NodeValueCommmand CreateSetValueCommand(
     VanillaXmlModelProvider provider, NodeValueChange change)
 {
     return new NodeValueCommmand(change);
 }
        internal SimpleTransaction(
            VanillaXmlModelProvider provider, string name, SimpleTransaction parent, SimpleTransactionManager mgr, object userState)
        {
            this.provider = provider;
            this.name = name;
            this.parent = parent;
            manager = mgr;
            DesignerTransaction = true;

            resources = new Dictionary<XDocument, SimpleTransactionLogger>();
            status = XmlTransactionStatus.Active;
            _userState = userState;
        }
 internal virtual RemoveNodeCommand CreateRemoveNodeCommand(
     VanillaXmlModelProvider provider, RemoveNodeChange change)
 {
     return new RemoveNodeCommand(change);
 }
 internal virtual AddNodeCommand CreateAddNodeCommand(
     VanillaXmlModelProvider provider, AddNodeChange change)
 {
     return new AddNodeCommand(change);
 }
 internal void SetCurrentTransaction(VanillaXmlModelProvider provider, SimpleTransaction tx)
 {
     if (_currentTransaction.ContainsKey(provider))
     {
         _currentTransaction[provider] = tx;
     }
     else
     {
         _currentTransaction.Add(provider, tx);
     }
 }
        internal SimpleTransaction GetCurrentTransaction(VanillaXmlModelProvider provider)
        {
            SimpleTransaction current = null;
            if (_currentTransaction.ContainsKey(provider))
            {
                current = _currentTransaction[provider];
            }

            return current;
        }
        internal SimpleTransaction BeginTransaction(
            VanillaXmlModelProvider provider, string name, SimpleTransaction parent, object userState)
        {
            var tx = new SimpleTransaction(provider, name, parent, this, userState);

            if (parent != null)
            {
                // Unsubscribe events on parent transaction
                parent.MakeInactive();

                // Create SimpleTransactionLogger for each document in VanillaXmlModelProvider
                foreach (var model in provider.OpenXmlModels)
                {
                    tx.EnlistResource(model as SimpleXmlModel);
                }
            }
            else
            {
                // This is the top level transaction, so acquire all locks to avoid deadlocks
                lock (this)
                {
                    foreach (var model in provider.OpenXmlModels)
                    {
                        tx.LockForWrite(model as SimpleXmlModel);
                    }
                }
            }

            // Make this the current Active transaction
            SetCurrentTransaction(provider, tx);
            tx.MakeActive();

            return tx;
        }