Exemplo n.º 1
0
 internal AmlElement(IElement newParent, IReadOnlyElement elem) : base()
 {
     _amlContext = newParent.AmlContext;
     _name       = elem.Name;
     _parent     = newParent;
     CopyData(elem);
 }
Exemplo n.º 2
0
 private bool SetCurrent(IReadOnlyElement elem)
 {
     _current = elem;
     _node    = XmlNodeType.Element;
     SetName(elem.Name);
     return(true);
 }
Exemplo n.º 3
0
        internal AmlNavigator(IReadOnlyElement elem)
        {
            var parents = new List <IReadOnlyElement>()
            {
                elem
            };
            var curr = elem;

            while (curr.Parent.Exists && !string.IsNullOrEmpty(curr.Parent.Name))
            {
                parents.Add(curr.Parent);
                curr = curr.Parent;
            }
            parents.Reverse();

            _stack.Push(new ElementList(parents[0]));
            _stack.Peek().MoveNext();
            for (var i = 1; i < parents.Count; i++)
            {
                var list = new ElementList(parents[i - 1].Elements());
                list.MoveTo(parents[i]);
                _stack.Push(list);
            }
            SetCurrent(_stack.Peek().Current);
        }
Exemplo n.º 4
0
 private bool SetCurrent(IReadOnlyElement elem)
 {
     _current   = elem;
     _node      = XmlNodeType.Element;
     _prefix    = elem.Prefix;
     _localName = elem.Name;
     return(true);
 }
Exemplo n.º 5
0
 private bool SetCurrent(IReadOnlyElement elem)
 {
     _current = elem;
     _node    = XPathNodeType.Element;
     SetName(elem.Name);
     _attrs = null;
     return(true);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Copies data from <paramref name="elem"/> into this instance.
 /// </summary>
 /// <param name="elem">The elem to copy from.</param>
 protected void CopyData(IReadOnlyElement elem)
 {
     Add(elem.Attributes());
     Add(elem.Elements());
     if (elem.Value != null)
     {
         Add(elem.Value);
     }
 }
Exemplo n.º 7
0
 public void AddMessage(params object[] content)
 {
     if (!_message.Exists)
     {
         _message = _amlContext.Element("Message", content);
     }
     else
     {
         ((IElement)_message).Add(content);
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Copies data from <paramref name="elem"/> into this instance.
        /// </summary>
        /// <param name="elem">The elem to copy from.</param>
        protected void CopyData(IReadOnlyElement elem)
        {
            Add(elem.Attributes());
            var elements = elem.Elements();

            if (elements.Any())
            {
                Add(elements);
            }
            else if (elem.Value != null)
            {
                Add(elem.Value); // Only set the value if there are no elements as it will overwrite the elements
            }
        }
Exemplo n.º 9
0
        private void RenderJson(JsonTextWriter json, IReadOnlyElement elem, bool root)
        {
            if (!elem.Attributes().Any() && !elem.Elements().Any())
            {
                json.WriteValue(elem.Value);
            }
            else
            {
                json.WriteStartObject();
                if (root && elem.Attribute("type").Exists)
                {
                    json.WriteProperty("@odata.type", "http://host/odata/$metadata#" + elem.Attribute("type").Value);
                }
                foreach (var attr in elem.Attributes())
                {
                    if (!(root && (attr.Name == "type" || attr.Name == "action")))
                    {
                        json.WriteProperty("@" + attr.Name, attr.Value);
                    }
                }

                if (elem.Elements().Any())
                {
                    foreach (var group in elem.Elements().GroupBy(e => e.Name))
                    {
                        json.WritePropertyName(group.Key);
                        var needsArray = group.Skip(1).Any();
                        if (needsArray)
                        {
                            json.WriteStartArray();
                        }
                        foreach (var child in group)
                        {
                            RenderJson(json, child, false);
                        }
                        if (needsArray)
                        {
                            json.WriteEndArray();
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(elem.Value))
                {
                    json.WriteProperty("#text", elem.Value);
                }


                json.WriteEndObject();
            }
        }
Exemplo n.º 10
0
        public override bool MoveTo(XPathNavigator other)
        {
            var aml = other as AmlNavigator;

            if (aml == null)
            {
                return(false);
            }

            _current = aml._current;
            if (aml._attrs != null)
            {
                _attrs = _current.Attributes().GetEnumerator();
                while (_attrs.MoveNext() && !_attrs.Current.Equals(aml._attrs.Current))
                {
                    ;
                }
            }
            _node      = aml._node;
            _localName = aml._localName;
            _prefix    = aml._prefix;
            _stack     = new Stack <ElementList>(aml._stack.Select(e => e.Clone()));
            return(true);
        }
Exemplo n.º 11
0
 internal AmlReader(IReadOnlyElement elem, XmlNameTable table)
 {
     _stack.Push(Enumerable.Repeat(elem, 1).GetEnumerator());
     _table = table;
 }
Exemplo n.º 12
0
 internal AmlReader(IReadOnlyElement elem) : this(elem, new NameTable())
 {
 }
Exemplo n.º 13
0
 public IdAnnotation(IReadOnlyElement parent, Guid value)
 {
     _parent = parent;
     _value  = value;
 }
Exemplo n.º 14
0
 internal void AddMessageNode(IReadOnlyElement message)
 {
     _message = message ?? AmlElement.NullElem;
 }
Exemplo n.º 15
0
 public Logical(IElement parent, IReadOnlyElement elem) : base(parent, elem)
 {
 }