public override void WriteEndObject() { _handled = false; switch (_mode) { case DeferringMode.Off: break; case DeferringMode.TemplateReady: throw new XamlInternalException(SR.Get(SRID.TemplateNotCollected, "WriteEndObject")); case DeferringMode.TemplateDeferring: _deferredWriter.WriteEndObject(); _handled = true; _deferredTreeDepth -= 1; if (_deferredTreeDepth == 0) { _deferredWriter.Close(); _deferredWriter = null; _mode = DeferringMode.TemplateReady; } break; default: throw new XamlInternalException(SR.Get(SRID.MissingCase, _mode.ToString(), "WriteEndObject")); } }
private void InterruptableTransform(XamlReader reader, XamlWriter writer, bool closeWriter) { IXamlLineInfo xamlLineInfo = reader as IXamlLineInfo; IXamlLineInfoConsumer xamlLineInfoConsumer = writer as IXamlLineInfoConsumer; bool shouldPassLineNumberInfo = false; if ((xamlLineInfo != null && xamlLineInfo.HasLineInfo) && (xamlLineInfoConsumer != null && xamlLineInfoConsumer.ShouldProvideLineInfo)) { shouldPassLineNumberInfo = true; } while (reader.Read()) { if (IsDisposed) { break; } if (shouldPassLineNumberInfo) { if (xamlLineInfo.LineNumber != 0) { xamlLineInfoConsumer.SetLineInfo(xamlLineInfo.LineNumber, xamlLineInfo.LinePosition); } } writer.WriteNode(reader); } if (closeWriter) { writer.Close(); } }
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(); } }
private void InterruptableTransform(XamlReader reader, XamlWriter writer, bool closeWriter) { IXamlLineInfo info = reader as IXamlLineInfo; IXamlLineInfoConsumer consumer = writer as IXamlLineInfoConsumer; bool flag = false; if (((info != null) && info.HasLineInfo) && ((consumer != null) && consumer.ShouldProvideLineInfo)) { flag = true; } while (reader.Read()) { if (base.IsDisposed) { break; } if (flag && (info.LineNumber != 0)) { consumer.SetLineInfo(info.LineNumber, info.LinePosition); } writer.WriteNode(reader); } if (closeWriter) { writer.Close(); } }
public static void Transform(XamlReader xamlReader, XamlWriter xamlWriter, bool closeWriter) { if (xamlReader == null) { throw new ArgumentNullException("xamlReader"); } if (xamlWriter == null) { throw new ArgumentNullException("xamlWriter"); } IXamlLineInfo info = xamlReader as IXamlLineInfo; IXamlLineInfoConsumer consumer = xamlWriter as IXamlLineInfoConsumer; bool flag = false; if (((info != null) && info.HasLineInfo) && ((consumer != null) && consumer.ShouldProvideLineInfo)) { flag = true; } while (xamlReader.Read()) { if (flag && (info.LineNumber != 0)) { consumer.SetLineInfo(info.LineNumber, info.LinePosition); } xamlWriter.WriteNode(xamlReader); } if (closeWriter) { xamlWriter.Close(); } }
// This method is a workaround for TFS bug #788190, since XamlReader.ReadSubtree() should (but doesn't) preserve IXamlLineInfo on the subreader public static void Transform(XamlReader reader, XamlWriter writer, IXamlLineInfo readerLineInfo, bool closeWriter) { IXamlLineInfoConsumer consumer = writer as IXamlLineInfoConsumer; SharedFx.Assert(consumer != null && consumer.ShouldProvideLineInfo, "Should only call this function to write into a XamlNodeQueue.Writer, which is always IXamlLineInfoConsumer"); bool shouldPassLineNumberInfo = false; if (readerLineInfo != null) { shouldPassLineNumberInfo = true; } while (reader.Read()) { if (shouldPassLineNumberInfo) { consumer.SetLineInfo(readerLineInfo.LineNumber, readerLineInfo.LinePosition); } writer.WriteNode(reader); } if (closeWriter) { writer.Close(); } }
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(); } }
// The "ThreadStart" function private void XamlReaderThreadStart(object none) { try { InterruptableTransform(_wrappedReader, _writer, true); } catch (Exception ex) { _writer.Close(); _caughtException = ex; } }
public static void Transform(XamlReader reader, XamlWriter writer, IXamlLineInfo readerLineInfo, bool closeWriter) { IXamlLineInfoConsumer consumer = writer as IXamlLineInfoConsumer; bool flag = false; if (readerLineInfo != null) { flag = true; } while (reader.Read()) { if (flag) { consumer.SetLineInfo(readerLineInfo.LineNumber, readerLineInfo.LinePosition); } writer.WriteNode(reader); } if (closeWriter) { writer.Close(); } }
public static void Transform(XamlReader xamlReader, XamlWriter xamlWriter, bool closeWriter) { if (xamlReader == null) { throw new ArgumentNullException(nameof(xamlReader)); } if (xamlWriter == null) { throw new ArgumentNullException(nameof(xamlWriter)); } IXamlLineInfo xamlLineInfo = xamlReader as IXamlLineInfo; IXamlLineInfoConsumer xamlLineInfoConsumer = xamlWriter as IXamlLineInfoConsumer; bool shouldPassLineNumberInfo = false; if ((xamlLineInfo != null && xamlLineInfo.HasLineInfo) && (xamlLineInfoConsumer != null && xamlLineInfoConsumer.ShouldProvideLineInfo)) { shouldPassLineNumberInfo = true; } while (xamlReader.Read()) { if (shouldPassLineNumberInfo) { if (xamlLineInfo.LineNumber != 0) { xamlLineInfoConsumer.SetLineInfo(xamlLineInfo.LineNumber, xamlLineInfo.LinePosition); } } xamlWriter.WriteNode(xamlReader); } if (closeWriter) { xamlWriter.Close(); } }
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 (); }
internal XamlReader ReadObject(KeyRecord record) { // This means we're at the end of the Deferred Content // Break out and return null if (record.ValuePosition == _binaryReader.BaseStream.Length) { return null; } _binaryReader.BaseStream.Seek(record.ValuePosition, SeekOrigin.Begin); _context.CurrentKey = _context.KeyList.IndexOf(record); if (_xamlMainNodeQueue.Count > 0) { // throw new XamlParseException(); } if (Read_RecordType() != Baml2006RecordType.ElementStart) { throw new XamlParseException(); } XamlWriter oldQueueWriter = _xamlNodesWriter; // estimates from statistical examiniation of Theme Resource Data. // small RD entries appear to have about a 2.2 bytes to XamlNode ration. // larger RD entries are less dense (due to data) at about 4.25. // Presizing the XamlNodeLists save upto 50% in memory useage for same. int initialSizeOfNodeList = (record.ValueSize < 800) ? (int)(record.ValueSize / 2.2) : (int)(record.ValueSize / 4.25); initialSizeOfNodeList = (initialSizeOfNodeList < 8) ? 8 : initialSizeOfNodeList; var result = new XamlNodeList(_xamlNodesReader.SchemaContext, initialSizeOfNodeList); _xamlNodesWriter = result.Writer; Baml2006ReaderFrame baseFrame = _context.CurrentFrame; Process_ElementStart(); while (baseFrame != _context.CurrentFrame) { Process_OneBamlRecord(); } _xamlNodesWriter.Close(); _xamlNodesWriter = oldQueueWriter; return result.GetReader(); }
public static void Transform(XamlReader xamlReader, XamlWriter xamlWriter, bool closeWriter) { if (xamlReader == null) { throw new ArgumentNullException("xamlReader"); } if (xamlWriter == null) { throw new ArgumentNullException("xamlWriter"); } IXamlLineInfo info = xamlReader as IXamlLineInfo; IXamlLineInfoConsumer consumer = xamlWriter as IXamlLineInfoConsumer; bool flag = false; if (((info != null) && info.HasLineInfo) && ((consumer != null) && consumer.ShouldProvideLineInfo)) { flag = true; } while (xamlReader.Read()) { if (flag && (info.LineNumber != 0)) { consumer.SetLineInfo(info.LineNumber, info.LinePosition); } xamlWriter.WriteNode(xamlReader); } if (closeWriter) { xamlWriter.Close(); } }
private void InterruptableTransform(XamlReader reader, XamlWriter writer, bool closeWriter) { IXamlLineInfo info = reader as IXamlLineInfo; IXamlLineInfoConsumer consumer = writer as IXamlLineInfoConsumer; bool flag = false; if (((info != null) && info.HasLineInfo) && ((consumer != null) && consumer.ShouldProvideLineInfo)) { flag = true; } while (reader.Read()) { if (base.IsDisposed) { break; } if (flag && (info.LineNumber != 0)) { consumer.SetLineInfo(info.LineNumber, info.LinePosition); } writer.WriteNode(reader); } if (closeWriter) { writer.Close(); } }