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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HwndProxyElementProvider.cs
- SqlDataSourceCommandEventArgs.cs
- DynamicQueryableWrapper.cs
- WizardStepCollectionEditor.cs
- QilPatternVisitor.cs
- StateChangeEvent.cs
- CookielessHelper.cs
- XPathNavigatorReader.cs
- Compiler.cs
- GPRECTF.cs
- CompatibleIComparer.cs
- AnimationClock.cs
- AnnotationResourceCollection.cs
- EmbeddedObject.cs
- ReachNamespaceInfo.cs
- StaticTextPointer.cs
- ResourceSet.cs
- PackagePartCollection.cs
- BuildProviderAppliesToAttribute.cs
- StylusPointPropertyId.cs
- OleDbInfoMessageEvent.cs
- SingleConverter.cs
- ScopelessEnumAttribute.cs
- WebPartZoneCollection.cs
- RowParagraph.cs
- tibetanshape.cs
- sqlmetadatafactory.cs
- MediaScriptCommandRoutedEventArgs.cs
- EntityCommandExecutionException.cs
- DbUpdateCommandTree.cs
- ComponentCommands.cs
- ErrorRuntimeConfig.cs
- MultiView.cs
- StyleXamlParser.cs
- XmlQualifiedNameTest.cs
- SpellCheck.cs
- StringComparer.cs
- FontCacheLogic.cs
- WebControlParameterProxy.cs
- ApplicationHost.cs
- SafeBitVector32.cs
- ValueTypeFixupInfo.cs
- FormsAuthenticationUser.cs
- AvtEvent.cs
- BaseParagraph.cs
- SqlNodeAnnotation.cs
- CaseCqlBlock.cs
- MsmqDecodeHelper.cs
- SectionInput.cs
- Drawing.cs
- BinaryObjectReader.cs
- X509Utils.cs
- TreeNode.cs
- ResolveRequestResponseAsyncResult.cs
- CurrentTimeZone.cs
- PromptEventArgs.cs
- ApplicationTrust.cs
- SaveFileDialog.cs
- EventLogEntryCollection.cs
- HttpListenerContext.cs
- WebPartEditorApplyVerb.cs
- Baml2006KnownTypes.cs
- PreviewPrintController.cs
- Comparer.cs
- PasswordRecoveryDesigner.cs
- SqlParameterCollection.cs
- DetailsViewModeEventArgs.cs
- PenLineCapValidation.cs
- DirectoryRootQuery.cs
- ListBindableAttribute.cs
- EarlyBoundInfo.cs
- VirtualPathProvider.cs
- XmlElementCollection.cs
- PositiveTimeSpanValidator.cs
- InternalException.cs
- XmlIlGenerator.cs
- UriScheme.cs
- StaticFileHandler.cs
- InkCanvasInnerCanvas.cs
- ControlParser.cs
- CodeTypeDelegate.cs
- SyntaxCheck.cs
- GeometryHitTestResult.cs
- FloaterParaClient.cs
- EventBuilder.cs
- ProviderManager.cs
- PropertyManager.cs
- PolyLineSegment.cs
- OrderedDictionaryStateHelper.cs
- WindowsAltTab.cs
- HttpsHostedTransportConfiguration.cs
- EdmType.cs
- PathFigureCollection.cs
- BamlLocalizationDictionary.cs
- mda.cs
- ReachIDocumentPaginatorSerializer.cs
- DistinctQueryOperator.cs
- TrackingConditionCollection.cs
- ImmComposition.cs
- EUCJPEncoding.cs