Пример #1
0
 void Changed(object sender, XObjectChangeEventArgs e)
 {
     _pending.Group = _lastGroup;
     if (_undoing)
     {
         _redos.Push(_pending);
     }
     else
     {
         _undos.Push(_pending);
     }
     _pending = null;
 }
Пример #2
0
 void Changed(object sender, XObjectChangeEventArgs e)
 {
     _pending.Group = _lastGroup;
     if (_undoing)
     {
         _redos.Push(_pending);
     }
     else
     {
         _undos.Push(_pending);
     }
     _pending = null;
 }
Пример #3
0
        void Changing(object sender, XObjectChangeEventArgs e)
        {
            if (_pending != null)
            {
                throw new NotImplementedException();
            }
            switch (e.ObjectChange)
            {
            case XObjectChange.Add:
                _pending = new AddUnit((XObject)sender);
                break;

            case XObjectChange.Remove:
                XContainer parent = ((XObject)sender).Parent;
                if (parent == null)
                {
                    parent = ((XObject)sender).Document;
                }
                XObject next = null;
                if (sender is XNode)
                {
                    next = ((XNode)sender).NextNode;
                }
                else if (sender is XAttribute)
                {
                    next = ((XAttribute)sender).NextAttribute;
                }
                _pending = new RemoveUnit((XObject)sender, parent, next);
                break;

            case XObjectChange.Name:
                object name = null;
                if (sender is XNode)
                {
                    switch (((XNode)sender).NodeType)
                    {
                    case XmlNodeType.Element:
                        name = ((XElement)sender).Name;
                        break;

                    case XmlNodeType.ProcessingInstruction:
                        name = ((XProcessingInstruction)sender).Target;
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }
                _pending = new NameUnit((XNode)sender, name);
                break;

            case XObjectChange.Value:
                string value = null;
                if (sender is XNode)
                {
                    switch (((XNode)sender).NodeType)
                    {
                    case XmlNodeType.Element:
                        value = ((XElement)sender).IsEmpty ? null : string.Empty;
                        break;

                    case XmlNodeType.Text:
                    case XmlNodeType.CDATA:
                        value = ((XText)sender).Value;
                        break;

                    case XmlNodeType.ProcessingInstruction:
                        value = ((XProcessingInstruction)sender).Data;
                        break;

                    case XmlNodeType.Comment:
                        value = ((XComment)sender).Value;
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }
                else if (sender is XAttribute)
                {
                    value = ((XAttribute)sender).Value;
                }
                _pending = new ValueUnit((XObject)sender, value);
                break;
            }
        }
Пример #4
0
 void Changing(object sender, XObjectChangeEventArgs e)
 {
     if (_pending != null) throw new NotImplementedException();
     switch (e.ObjectChange)
     {
         case XObjectChange.Add:
             _pending = new AddUnit((XObject)sender);
             break;
         case XObjectChange.Remove:
             XContainer parent = ((XObject)sender).Parent;
             if (parent == null)
             {
                 parent = ((XObject)sender).Document;
             }
             XObject next = null;
             if (sender is XNode)
             {
                 next = ((XNode)sender).NextNode;
             }
             else if (sender is XAttribute)
             {
                 next = ((XAttribute)sender).NextAttribute;
             }
             _pending = new RemoveUnit((XObject)sender, parent, next);
             break;
         case XObjectChange.Name:
             object name = null;
             if (sender is XNode)
             {
                 switch (((XNode)sender).NodeType)
                 {
                     case XmlNodeType.Element:
                         name = ((XElement)sender).Name;
                         break;
                     case XmlNodeType.ProcessingInstruction:
                         name = ((XProcessingInstruction)sender).Target;
                         break;
                     default:
                         throw new NotImplementedException();
                 }
             }
             _pending = new NameUnit((XNode)sender, name);
             break;
         case XObjectChange.Value:
             string value = null;
             if (sender is XNode)
             {
                 switch (((XNode)sender).NodeType)
                 {
                     case XmlNodeType.Element:
                         value = ((XElement)sender).IsEmpty ? null : string.Empty;
                         break;
                     case XmlNodeType.Text:
                     case XmlNodeType.CDATA:
                         value = ((XText)sender).Value;
                         break;
                     case XmlNodeType.ProcessingInstruction:
                         value = ((XProcessingInstruction)sender).Data;
                         break;
                     case XmlNodeType.Comment:
                         value = ((XComment)sender).Value;
                         break;
                     default:
                         throw new NotImplementedException();
                 }
             }
             else if (sender is XAttribute)
             {
                 value = ((XAttribute)sender).Value;
             }
             _pending = new ValueUnit((XObject)sender, value);
             break;
     }
 }