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
- Screen.cs
- WebRequestModulesSection.cs
- RoleManagerModule.cs
- ObjectStorage.cs
- LabelAutomationPeer.cs
- SqlServices.cs
- StyleHelper.cs
- StatusBarPanel.cs
- DeadCharTextComposition.cs
- PersonalizationState.cs
- XmlBindingWorker.cs
- StaticSiteMapProvider.cs
- TransformerConfigurationWizardBase.cs
- TraceSource.cs
- HttpListenerResponse.cs
- shaper.cs
- SourceElementsCollection.cs
- RoutedCommand.cs
- DebuggerAttributes.cs
- MissingFieldException.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- HtmlTableRow.cs
- MediaSystem.cs
- AnnotationAdorner.cs
- DLinqColumnProvider.cs
- XmlStringTable.cs
- OdbcRowUpdatingEvent.cs
- SQLInt64.cs
- Grid.cs
- WindowsEditBoxRange.cs
- PageContentAsyncResult.cs
- TextElementCollection.cs
- SQLGuidStorage.cs
- NumberFunctions.cs
- TerminatorSinks.cs
- SmiRecordBuffer.cs
- ToolStripSettings.cs
- MarkedHighlightComponent.cs
- SystemWebCachingSectionGroup.cs
- XmlSchemaObjectTable.cs
- FontWeight.cs
- WebPartAddingEventArgs.cs
- PassportAuthentication.cs
- CodeIdentifiers.cs
- DateTimeFormatInfo.cs
- WebPartConnectionsCancelVerb.cs
- CommandDevice.cs
- Geometry.cs
- RemoteWebConfigurationHostStream.cs
- SoapIncludeAttribute.cs
- EmptyStringExpandableObjectConverter.cs
- AutomationProperty.cs
- QueryOptionExpression.cs
- HMACSHA384.cs
- XmlSchemaAny.cs
- TypeReference.cs
- SqlTrackingWorkflowInstance.cs
- ConstNode.cs
- Attributes.cs
- Bidi.cs
- OdbcConnectionHandle.cs
- DataGridTableStyleMappingNameEditor.cs
- NotSupportedException.cs
- MutableAssemblyCacheEntry.cs
- CodeTypeReference.cs
- DrawingGroupDrawingContext.cs
- CombinedTcpChannel.cs
- ADConnectionHelper.cs
- Package.cs
- ToolStripItem.cs
- InputElement.cs
- WmlPhoneCallAdapter.cs
- NativeStructs.cs
- DbConnectionPool.cs
- TimeSpanOrInfiniteValidator.cs
- embossbitmapeffect.cs
- SerialPinChanges.cs
- ScrollPatternIdentifiers.cs
- FixedSOMLineCollection.cs
- ClientSettings.cs
- DirtyTextRange.cs
- ScriptRef.cs
- ViewLoader.cs
- HttpListenerRequest.cs
- SamlAction.cs
- PostBackOptions.cs
- ToolStrip.cs
- ArgIterator.cs
- Privilege.cs
- MetadataSource.cs
- ByteAnimationBase.cs
- MouseButton.cs
- PublisherIdentityPermission.cs
- SqlInternalConnectionTds.cs
- PrintPreviewControl.cs
- DependencyObject.cs
- Light.cs
- WebServiceData.cs
- WSMessageEncoding.cs
- UdpDiscoveryEndpoint.cs