Exemplo n.º 1
0
        public void WriteNode(PropertyTreeReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader"); // $NON-NLS-1
            }
            int initialDepth = reader.Depth;

            do
            {
                switch (reader.NodeType)
                {
                case PropertyNodeType.EndPropertyTree:
                    this.WriteEndTree();
                    break;

                case PropertyNodeType.Property:
                    this.WriteProperty(reader.Name, reader.Namespace, Convert.ToString(reader.Value));

                    break;

                case PropertyNodeType.PropertyTree:
                    this.WriteStartTree(reader.Name, reader.Namespace);
                    break;
                }
            } while (reader.Read() &&
                     ((initialDepth < reader.Depth) ||
                      (initialDepth == reader.Depth && reader.NodeType == PropertyNodeType.EndPropertyTree)));
        }
        public void CopyFrom(PropertyTreeReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            reader.CopyTo(this);
        }
Exemplo n.º 3
0
 public static T ReadPropertyTree <T>(this StreamContext streamContext, Type type, Encoding encoding = null, PropertyTreeReaderSettings settings = null)
 {
     using (var reader = PropertyTreeReader.Create(streamContext, encoding, settings)) {
         reader.Read();
         return(reader.Bind <T>());
     }
 }
Exemplo n.º 4
0
        internal bool CopyCurrent(PropertyTreeReader reader)
        {
            if (reader.MoveToContent())
            {
                SetLineInfo(reader as IXmlLineInfo ?? Utility.NullLineInfo, reader.PrefixMap, reader as IUriContext);
                SetExpressNamespace(reader.IsExpressNamespace);

                switch (reader.NodeType)
                {
                case PropertyNodeType.Property:
                    WriteProperty(reader.Name, reader.Namespace, reader.Value);
                    return(true);

                case PropertyNodeType.PropertyTree:
                    this.WriteStartTree(reader.Name, reader.Namespace);
                    return(true);

                case PropertyNodeType.EndPropertyTree:
                    this.WriteEndTree();
                    return(true);
                }
            }

            return(false);
        }
        public void CopySubtreeFrom(PropertyTreeReader reader)
        {
            // CopyContentsFrom?
            if (reader == null)
                throw new ArgumentNullException("reader");

            reader.CopySubtreeTo(this);
        }
Exemplo n.º 6
0
 public void ReadSubtree(PropertyTreeReader reader)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("reader"); // $NON-NLS-1
     }
     _ReadSubtree(reader, reader.Depth);
 }
Exemplo n.º 7
0
        public void CopyFrom(PropertyTreeReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            reader.CopyTo(this);
        }
Exemplo n.º 8
0
        public void CopySubtreeFrom(PropertyTreeReader reader)   // CopyContentsFrom?
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            reader.CopySubtreeTo(this);
        }
Exemplo n.º 9
0
        public PropertyNode Append(PropertyTreeReader newChild)
        {
            if (newChild == null)
            {
                throw new ArgumentNullException(nameof(newChild));
            }

            Append().CopyFrom(newChild);
            return(this);
        }
        public virtual PropertyTreeNavigator Append(PropertyTreeReader newChild)
        {
            if (newChild == null)
            {
                throw new ArgumentNullException(nameof(newChild));
            }

            Append().ReadToEnd(newChild);
            return(this);
        }
Exemplo n.º 11
0
        public override object Load(StreamContext inputSource, Type instanceType)
        {
            if (inputSource == null)
            {
                throw new ArgumentNullException("inputSource");
            }
            var ptx = PropertyTreeReader.Create(inputSource);

            return(ptx.Bind(instanceType));
        }
Exemplo n.º 12
0
 public static PropertyTree FromStreamContext(StreamContext streamContext, Encoding encoding = null)
 {
     if (streamContext == null)
     {
         throw new ArgumentNullException("streamContext"); // $NON-NLS-1
     }
     using (PropertyTreeReader reader = PropertyTreeReader.CreateXml(streamContext, encoding, null)) {
         return(reader.ReadPropertyTree());
     }
 }
        public virtual PropertyTreeNavigator Append(PropertyTreeNavigator newChild)
        {
            if (newChild == null)
            {
                throw new ArgumentNullException("newChild");
            }

            PropertyTreeReader reader = CreateReader();

            return(Append(reader));
        }
Exemplo n.º 14
0
        void _ReadSubtree(PropertyTreeReader reader, int depth)
        {
            while (reader.Read())
            {
                CopyCurrent(reader); // TODO Exceptions generated by the write here (invalid local name) should be detected earlier and have line numbers

                if (reader.NodeType == PropertyNodeType.EndPropertyTree ||
                    reader.NodeType == PropertyNodeType.Property)
                {
                    if (reader.Depth == depth)
                    {
                        break;
                    }
                }
            }
        }
Exemplo n.º 15
0
 public static PropertyTree FromStream(Stream stream,
                                       Encoding encoding = null)
 {
     if (stream == null)
     {
         throw new ArgumentNullException("stream"); // $NON-NLS-1
     }
     using (var reader = PropertyTreeReader.CreateXml(stream, encoding, null)) {
         if (reader.Read())
         {
             return(reader.ReadPropertyTree());
         }
         else
         {
             throw Failure.Eof();
         }
     }
 }
        public void ReadToEnd(PropertyTreeReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader"); // $NON-NLS-1

            _ReadSubtree(reader, -1);
        }
Exemplo n.º 17
0
 public new PropertyTree Append(PropertyTreeReader newChild)
 {
     return((PropertyTree)base.Append(newChild));
 }
 static Func <StreamContext, Encoding, PropertyTreeReaderSettings, PropertyTreeReader> GetFactoryFunc(string lp)
 {
     return((s, e, settings) => (PropertyTreeReader.CreateXml(s, e, new PropertyTreeXmlReaderSettings(settings))));
 }
        public void WriteNode(PropertyTreeReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader"); // $NON-NLS-1

            int initialDepth = reader.Depth;
            do {
                switch (reader.NodeType) {
                    case PropertyNodeType.EndPropertyTree:
                        this.WriteEndTree();
                        break;

                    case PropertyNodeType.Property:
                        this.WriteProperty(reader.Name, reader.Namespace, Convert.ToString(reader.Value));

                        break;

                    case PropertyNodeType.PropertyTree:
                        this.WriteStartTree(reader.Name, reader.Namespace);
                        break;
                }

            } while (reader.Read()
                     && ((initialDepth < reader.Depth)
                         || (initialDepth == reader.Depth && reader.NodeType == PropertyNodeType.EndPropertyTree)));
        }
        internal bool CopyCurrent(PropertyTreeReader reader)
        {
            if (reader.MoveToContent()) {
                SetLineInfo(reader as IXmlLineInfo ?? Utility.NullLineInfo, reader.PrefixMap, reader as IUriContext);
                SetExpressNamespace(reader.IsExpressNamespace);

                switch (reader.NodeType) {
                    case PropertyNodeType.Property:
                        this.WriteProperty(reader.Name, reader.Namespace, Convert.ToString(reader.Value));
                        return true;

                    case PropertyNodeType.PropertyTree:
                        this.WriteStartTree(reader.Name, reader.Namespace);
                        return true;

                    case PropertyNodeType.EndPropertyTree:
                        this.WriteEndTree();
                        return true;
                }
            }

            return false;
        }
        void _ReadSubtree(PropertyTreeReader reader, int depth)
        {
            while (reader.Read()) {
                CopyCurrent(reader); // TODO Exceptions generated by the write here (invalid local name) should be detected earlier and have line numbers

                if (reader.NodeType == PropertyNodeType.EndPropertyTree
                    || reader.NodeType == PropertyNodeType.Property) {

                    if (reader.Depth == depth)
                        break;
                }
            }
        }
 public static PropertyTreeXmlReader Create(string inputFileName, Encoding encoding = null, PropertyTreeXmlReaderSettings settings = null)
 {
     return(PropertyTreeReader.CreateXml(inputFileName, encoding, settings));
 }
 public static PropertyTreeXmlReader Create(XmlReader inputReader, PropertyTreeXmlReaderSettings settings = null)
 {
     return(PropertyTreeReader.CreateXml(inputReader, settings));
 }
 public static PropertyTreeXmlReader Create(Stream inputStream, Encoding encoding = null, PropertyTreeXmlReaderSettings settings = null)
 {
     return(PropertyTreeReader.CreateXml(inputStream, encoding, settings));
 }