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
- TemplateEditingVerb.cs
- MsmqIntegrationBindingElement.cs
- ProfileInfo.cs
- WindowsToolbarAsMenu.cs
- ImageKeyConverter.cs
- EmbeddedMailObject.cs
- AllMembershipCondition.cs
- TableLayoutPanel.cs
- Base64Stream.cs
- MessagePropertyVariants.cs
- RichTextBoxAutomationPeer.cs
- EmptyQuery.cs
- Quaternion.cs
- GlobalizationSection.cs
- HttpGetProtocolReflector.cs
- PeerInputChannelListener.cs
- _OSSOCK.cs
- X509Certificate.cs
- AssemblyBuilderData.cs
- NullToBooleanConverter.cs
- XsltQilFactory.cs
- IsolatedStorageFileStream.cs
- ObjectView.cs
- SynchronizationLockException.cs
- XPathDocument.cs
- ListBoxItem.cs
- PrintPreviewDialog.cs
- GridViewRowEventArgs.cs
- XamlSerializerUtil.cs
- ThreadExceptionEvent.cs
- TextRange.cs
- DataTableTypeConverter.cs
- LightweightCodeGenerator.cs
- TypeElement.cs
- WebReferencesBuildProvider.cs
- SchemaType.cs
- WmpBitmapDecoder.cs
- ZipFileInfoCollection.cs
- SpeechSeg.cs
- RegistryPermission.cs
- TraceListener.cs
- ScaleTransform3D.cs
- ProfileParameter.cs
- ListChangedEventArgs.cs
- DbExpressionBuilder.cs
- XPathMultyIterator.cs
- ViewStateModeByIdAttribute.cs
- LayoutUtils.cs
- DiffuseMaterial.cs
- FileDetails.cs
- FormClosingEvent.cs
- WpfWebRequestHelper.cs
- DataGridViewColumnDesigner.cs
- MaskDescriptors.cs
- ReflectionUtil.cs
- SerializationInfo.cs
- DetailsViewRowCollection.cs
- Constraint.cs
- ExpressionCopier.cs
- LineSegment.cs
- MexHttpsBindingElement.cs
- SoapIncludeAttribute.cs
- OleDbInfoMessageEvent.cs
- ListViewContainer.cs
- RegularExpressionValidator.cs
- TextChange.cs
- ThreadInterruptedException.cs
- DataConnectionHelper.cs
- SettingsPropertyWrongTypeException.cs
- SocketAddress.cs
- TextModifier.cs
- ComponentDesigner.cs
- EtwTrace.cs
- Normalization.cs
- Propagator.Evaluator.cs
- WindowCollection.cs
- LinqDataSourceContextData.cs
- ProfilePropertySettingsCollection.cs
- BinHexDecoder.cs
- BamlLocalizabilityResolver.cs
- TreeNode.cs
- HostingEnvironmentException.cs
- RepeatBehaviorConverter.cs
- FloaterParagraph.cs
- DependencyPropertyValueSerializer.cs
- WindowsScroll.cs
- SuppressMergeCheckAttribute.cs
- RelationshipEndCollection.cs
- CatalogPartDesigner.cs
- CodePageUtils.cs
- DynamicILGenerator.cs
- CookieParameter.cs
- LicFileLicenseProvider.cs
- DocumentCollection.cs
- FlowDocument.cs
- RangeBase.cs
- OverlappedAsyncResult.cs
- DynamicRendererThreadManager.cs
- SafeCancelMibChangeNotify.cs
- CommandBinding.cs