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
- ListView.cs
- PartialTrustVisibleAssembly.cs
- GridViewUpdatedEventArgs.cs
- FixedTextContainer.cs
- WindowHideOrCloseTracker.cs
- TypeDescriptor.cs
- ExpressionConverter.cs
- NotifyInputEventArgs.cs
- Translator.cs
- GridViewRowEventArgs.cs
- VariableQuery.cs
- SizeFConverter.cs
- MonthCalendar.cs
- Types.cs
- TimelineGroup.cs
- ToggleButtonAutomationPeer.cs
- SQLInt32Storage.cs
- Odbc32.cs
- WindowShowOrOpenTracker.cs
- LowerCaseStringConverter.cs
- DrawingAttributeSerializer.cs
- DataBinding.cs
- HttpCapabilitiesSectionHandler.cs
- LoginCancelEventArgs.cs
- BamlLocalizabilityResolver.cs
- DesignerLabelAdapter.cs
- XmlHierarchicalDataSourceView.cs
- DataGridViewAccessibleObject.cs
- XmlSortKey.cs
- JulianCalendar.cs
- KnownColorTable.cs
- ConsoleKeyInfo.cs
- XmlSchemaAnnotation.cs
- PartialTrustVisibleAssemblyCollection.cs
- DataGridViewSelectedRowCollection.cs
- EntityCommandCompilationException.cs
- ResourceSet.cs
- ResourcePermissionBase.cs
- AssociationSetEnd.cs
- IsolatedStorageFile.cs
- WinEventTracker.cs
- Point3DCollection.cs
- OutputCacheModule.cs
- TextParaLineResult.cs
- UiaCoreApi.cs
- CodeFieldReferenceExpression.cs
- COM2ColorConverter.cs
- InheritedPropertyChangedEventArgs.cs
- RunWorkerCompletedEventArgs.cs
- CoTaskMemHandle.cs
- StaticExtension.cs
- Page.cs
- DoubleCollectionConverter.cs
- CompositeActivityDesigner.cs
- ToolbarAUtomationPeer.cs
- HtmlSelect.cs
- HttpStreamXmlDictionaryWriter.cs
- Help.cs
- CheckBox.cs
- LeafCellTreeNode.cs
- MaskedTextBoxDesigner.cs
- MarkedHighlightComponent.cs
- SelectorItemAutomationPeer.cs
- PresentationSource.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- WebServiceTypeData.cs
- StorageScalarPropertyMapping.cs
- StringUtil.cs
- AVElementHelper.cs
- ClickablePoint.cs
- ErrorProvider.cs
- ColumnWidthChangingEvent.cs
- DispatcherHookEventArgs.cs
- RIPEMD160Managed.cs
- Privilege.cs
- CodeSubDirectory.cs
- WebInvokeAttribute.cs
- ComponentDesigner.cs
- PrimitiveCodeDomSerializer.cs
- Decorator.cs
- DefaultAutoFieldGenerator.cs
- ObjectSecurity.cs
- SetIterators.cs
- AccessedThroughPropertyAttribute.cs
- ToolbarAUtomationPeer.cs
- Rectangle.cs
- TableAutomationPeer.cs
- NamedElement.cs
- PathFigureCollection.cs
- CodeIdentifier.cs
- Sentence.cs
- RegexMatch.cs
- WebBrowserDocumentCompletedEventHandler.cs
- ContainerSelectorBehavior.cs
- Range.cs
- DesignerCapabilities.cs
- MessagePropertyVariants.cs
- UserInitiatedNavigationPermission.cs
- PriorityRange.cs
- X509Certificate.cs