Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / XamlIntegration / XamlWriterExtensions.cs / 1305376 / XamlWriterExtensions.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.XamlIntegration { using System; using System.Xaml; using System.Runtime; static class XamlWriterExtensions { public static void PropagateLineInfo(XamlWriter targetWriter, IXamlLineInfo lineInfo) { if (lineInfo != null) { IXamlLineInfoConsumer consumer = targetWriter as IXamlLineInfoConsumer; Fx.Assert(consumer != null && consumer.ShouldProvideLineInfo, "Should only call this function to write into a XamlNodeQueue.Writer, which is always IXamlLineInfoConsumer"); consumer.SetLineInfo(lineInfo.LineNumber, lineInfo.LinePosition); } } public static void PropagateLineInfo(XamlWriter targetWriter, int lineNumber, int linePosition) { IXamlLineInfoConsumer consumer = targetWriter as IXamlLineInfoConsumer; Fx.Assert(consumer != null && consumer.ShouldProvideLineInfo, "Should only call this function to write into a XamlNodeQueue.Writer, which is always IXamlLineInfoConsumer"); consumer.SetLineInfo(lineNumber, linePosition); } // 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; Fx.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 WriteNode(this XamlWriter writer, XamlReader reader, IXamlLineInfo lineInfo) { PropagateLineInfo(writer, lineInfo); writer.WriteNode(reader); } public static void WriteEndMember(this XamlWriter writer, IXamlLineInfo lineInfo) { PropagateLineInfo(writer, lineInfo); writer.WriteEndMember(); } public static void WriteEndObject(this XamlWriter writer, IXamlLineInfo lineInfo) { PropagateLineInfo(writer, lineInfo); writer.WriteEndObject(); } public static void WriteGetObject(this XamlWriter writer, IXamlLineInfo lineInfo) { PropagateLineInfo(writer, lineInfo); writer.WriteGetObject(); } public static void WriteNamespace(this XamlWriter writer, NamespaceDeclaration namespaceDeclaration, IXamlLineInfo lineInfo) { PropagateLineInfo(writer, lineInfo); writer.WriteNamespace(namespaceDeclaration); } public static void WriteStartMember(this XamlWriter writer, XamlMember xamlMember, IXamlLineInfo lineInfo) { PropagateLineInfo(writer, lineInfo); writer.WriteStartMember(xamlMember); } public static void WriteStartMember(this XamlWriter writer, XamlMember xamlMember, int lineNumber, int linePosition) { PropagateLineInfo(writer, lineNumber, linePosition); writer.WriteStartMember(xamlMember); } public static void WriteStartObject(this XamlWriter writer, XamlType type, IXamlLineInfo lineInfo) { PropagateLineInfo(writer, lineInfo); writer.WriteStartObject(type); } public static void WriteValue(this XamlWriter writer, object value, IXamlLineInfo lineInfo) { PropagateLineInfo(writer, lineInfo); writer.WriteValue(value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- NestedContainer.cs
- XmlText.cs
- MultipleViewProviderWrapper.cs
- ObjectAnimationBase.cs
- ConfigurationSchemaErrors.cs
- ConfigXmlReader.cs
- LineBreakRecord.cs
- WaveHeader.cs
- RectAnimationBase.cs
- SectionUpdates.cs
- UseLicense.cs
- HttpRawResponse.cs
- BlurBitmapEffect.cs
- CategoriesDocument.cs
- Label.cs
- ActiveDocumentEvent.cs
- DataGridViewColumnDesignTimeVisibleAttribute.cs
- APCustomTypeDescriptor.cs
- TemplatedAdorner.cs
- VersionPair.cs
- ImageKeyConverter.cs
- MatrixTransform.cs
- ReaderOutput.cs
- SqlReferenceCollection.cs
- TimeSpanValidatorAttribute.cs
- LogLogRecord.cs
- WeakReadOnlyCollection.cs
- PassportAuthenticationModule.cs
- SingleTagSectionHandler.cs
- ToolStripSplitStackLayout.cs
- DataGridViewColumnCollection.cs
- BamlLocalizationDictionary.cs
- ButtonBase.cs
- ToolBar.cs
- EventPrivateKey.cs
- errorpatternmatcher.cs
- XmlRootAttribute.cs
- UnmanagedMarshal.cs
- BaseProcessor.cs
- HMACRIPEMD160.cs
- CacheSection.cs
- PenLineCapValidation.cs
- MessageQueuePermissionAttribute.cs
- NullReferenceException.cs
- PassportPrincipal.cs
- TabPage.cs
- Vector3DConverter.cs
- BufferedGraphicsManager.cs
- SimpleMailWebEventProvider.cs
- RelationshipEnd.cs
- SiteMapHierarchicalDataSourceView.cs
- RoutedEventArgs.cs
- Debug.cs
- CultureInfoConverter.cs
- NullRuntimeConfig.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- NopReturnReader.cs
- StyleModeStack.cs
- NavigationService.cs
- Version.cs
- SortAction.cs
- ImageBrush.cs
- PolyLineSegment.cs
- GrammarBuilderRuleRef.cs
- OutKeywords.cs
- DataGridViewCellStyleConverter.cs
- ExpressionVisitor.cs
- EventLogger.cs
- SynchronizedInputHelper.cs
- webbrowsersite.cs
- InternalBufferManager.cs
- TypeNameParser.cs
- ControlCachePolicy.cs
- ConfigXmlSignificantWhitespace.cs
- PeerResolverElement.cs
- basecomparevalidator.cs
- StreamGeometry.cs
- Brush.cs
- DispatcherFrame.cs
- HtmlPageAdapter.cs
- WeakReferenceKey.cs
- Switch.cs
- ComPlusThreadInitializer.cs
- StaticContext.cs
- Utils.cs
- DefaultValueConverter.cs
- HandleRef.cs
- OdbcCommand.cs
- CompoundFileDeflateTransform.cs
- RenderDataDrawingContext.cs
- JulianCalendar.cs
- Color.cs
- HttpConfigurationSystem.cs
- DataGridColumnFloatingHeader.cs
- Pair.cs
- Renderer.cs
- NameValueFileSectionHandler.cs
- Adorner.cs
- ConfigXmlElement.cs
- SourceSwitch.cs