Пример #1
0
        public static void Transform(XamlReader xamlReader, XamlWriter xamlWriter, bool closeWriter)
        {
            if (xamlReader == null)
            {
                throw new ArgumentNullException("xamlReader");
            }
            if (xamlWriter == null)
            {
                throw new ArgumentNullException("xamlWriter");
            }

            if (xamlReader.NodeType == XamlNodeType.None)
            {
                xamlReader.Read();
            }

            var xamlLineInfo      = xamlReader as IXamlLineInfo;
            var xamlLineConsumer  = xamlWriter as IXamlLineInfoConsumer;
            var shouldSetLineInfo = xamlLineInfo != null && xamlLineConsumer != null && xamlLineConsumer.ShouldProvideLineInfo && xamlLineInfo.HasLineInfo;

            while (!xamlReader.IsEof)
            {
                if (shouldSetLineInfo)
                {
                    xamlLineConsumer.SetLineInfo(xamlLineInfo.LineNumber, xamlLineInfo.LinePosition);
                }
                xamlWriter.WriteNode(xamlReader);
                xamlReader.Read();
            }
            if (closeWriter)
            {
                xamlWriter.Close();
            }
        }
Пример #2
0
        public static void Transform(XamlReader xamlReader, XamlWriter xamlWriter, bool closeWriter)
        {
            if (xamlReader == null)
            {
                throw new ArgumentNullException("xamlReader");
            }
            if (xamlWriter == null)
            {
                throw new ArgumentNullException("xamlWriter");
            }

            if (xamlReader.NodeType == XamlNodeType.None)
            {
                xamlReader.Read();
            }

            while (!xamlReader.IsEof)
            {
                xamlWriter.WriteNode(xamlReader);
                xamlReader.Read();
            }
            if (closeWriter)
            {
                xamlWriter.Close();
            }
        }
Пример #3
0
        public override bool Read()
        {
            if (started)
            {
                if (nest == 0)
                {
                    source.Read();
                    return(false);                    // already consumed
                }
                if (!source.Read())
                {
                    return(false);
                }
            }
            else
            {
                started = true;
            }

            switch (source.NodeType)
            {
            case XamlNodeType.StartObject:
            case XamlNodeType.GetObject:
            case XamlNodeType.StartMember:
                nest++;
                break;

            case XamlNodeType.EndObject:
            case XamlNodeType.EndMember:
                nest--;
                break;
            }
            return(true);
        }
Пример #4
0
 public void StartThread(string threadName)
 {
                 #if PCL136
     ThreadPool.QueueUserWorkItem(state =>
                 #else
     if (thread != null)
     {
         throw new InvalidOperationException("Thread has already started");
     }
     thread = Task.Run(() =>
                 #endif
     {
         try {
             while (do_work && r.Read())
             {
                 q.Writer.WriteNode(r);
                 wait.Set();
             }
         } catch (Exception ex) {
             lastError = ex;
             wait.Set();
         } finally {
             read_all_done = true;
         }
     });
 }
Пример #5
0
		public static void Transform (XamlReader xamlReader, XamlWriter xamlWriter, bool closeWriter)
		{
			if (xamlReader == null)
				throw new ArgumentNullException ("xamlReader");
			if (xamlWriter == null)
				throw new ArgumentNullException ("xamlWriter");

			if (xamlReader.NodeType == XamlNodeType.None)
				xamlReader.Read ();

			while (!xamlReader.IsEof) {
				xamlWriter.WriteNode (xamlReader);
				xamlReader.Read ();
			}
			if (closeWriter)
				xamlWriter.Close ();
		}