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
- FontFamilyValueSerializer.cs
- ByteStream.cs
- UserPersonalizationStateInfo.cs
- SystemParameters.cs
- SemanticAnalyzer.cs
- DocumentsTrace.cs
- ReflectTypeDescriptionProvider.cs
- TypeFieldSchema.cs
- EastAsianLunisolarCalendar.cs
- SelectorItemAutomationPeer.cs
- UnorderedHashRepartitionStream.cs
- ReferenceEqualityComparer.cs
- BufferAllocator.cs
- MatrixTransform3D.cs
- SchemaImporterExtensionElementCollection.cs
- PropertyInformationCollection.cs
- MarkupObject.cs
- Group.cs
- XmlCharCheckingReader.cs
- HwndTarget.cs
- OracleString.cs
- StructuralObject.cs
- TreeViewImageKeyConverter.cs
- DoWorkEventArgs.cs
- Emitter.cs
- MemberCollection.cs
- MatcherBuilder.cs
- SHA1CryptoServiceProvider.cs
- ListItemCollection.cs
- ControlValuePropertyAttribute.cs
- NameTable.cs
- EntityDataSourceContainerNameItem.cs
- UrlMappingCollection.cs
- ToolStripItemImageRenderEventArgs.cs
- XmlBoundElement.cs
- HtmlEncodedRawTextWriter.cs
- SubstitutionList.cs
- CalloutQueueItem.cs
- LogFlushAsyncResult.cs
- CodeIndexerExpression.cs
- EventProviderBase.cs
- XmlEntity.cs
- QuadraticBezierSegment.cs
- Delegate.cs
- XmlHierarchicalDataSourceView.cs
- Menu.cs
- Int64.cs
- DbConnectionHelper.cs
- Style.cs
- SqlParameter.cs
- ScriptComponentDescriptor.cs
- DataGridViewIntLinkedList.cs
- FormViewModeEventArgs.cs
- XMLSchema.cs
- ObjectRef.cs
- SourceSwitch.cs
- XmlSchemaElement.cs
- LOSFormatter.cs
- PrefixQName.cs
- PersonalizablePropertyEntry.cs
- HasCopySemanticsAttribute.cs
- ThicknessAnimationBase.cs
- ReflectPropertyDescriptor.cs
- TypeDescriptionProviderAttribute.cs
- IRCollection.cs
- ProxyWebPartManager.cs
- FontDriver.cs
- InternalResources.cs
- TripleDES.cs
- EventLogConfiguration.cs
- Size.cs
- ImportException.cs
- MethodImplAttribute.cs
- ObjRef.cs
- ToolStripManager.cs
- PackageRelationshipCollection.cs
- FeatureSupport.cs
- XpsFilter.cs
- FileUtil.cs
- ResourceDescriptionAttribute.cs
- ProviderConnectionPoint.cs
- FactoryGenerator.cs
- KeyedHashAlgorithm.cs
- WebControl.cs
- DataGridTemplateColumn.cs
- GregorianCalendar.cs
- OAVariantLib.cs
- ConditionalDesigner.cs
- SafeRightsManagementQueryHandle.cs
- NamedPipeTransportBindingElement.cs
- TemplatedControlDesigner.cs
- DiagnosticsElement.cs
- BevelBitmapEffect.cs
- designeractionbehavior.cs
- ClientReliableChannelBinder.cs
- TextTreeDeleteContentUndoUnit.cs
- Focus.cs
- DisplayNameAttribute.cs
- SingleAnimationBase.cs
- ValidationSummary.cs