Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / XmlUtils / System / Xml / Xsl / Xslt / QilStrConcatenator.cs / 1305376 / QilStrConcatenator.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System.Diagnostics; using System.Xml; using System.Text; using System.Xml.Schema; using System.Xml.Xsl.XPath; using System.Xml.Xsl.Qil; namespace System.Xml.Xsl.Xslt { internal class QilStrConcatenator { private XPathQilFactory f; private StringBuilder builder; private QilList concat; private bool inUse = false; public QilStrConcatenator(XPathQilFactory f) { this.f = f; builder = new StringBuilder(); } public void Reset() { Debug.Assert(! inUse); inUse = true; builder.Length = 0; concat = null; } private void FlushBuilder() { if (concat == null) { concat = f.BaseFactory.Sequence(); } if (builder.Length != 0) { concat.Add(f.String(builder.ToString())); builder.Length = 0; } } public void Append(string value) { Debug.Assert(inUse, "Reset() wasn't called"); builder.Append(value); } public void Append(char value) { Debug.Assert(inUse, "Reset() wasn't called"); builder.Append(value); } public void Append(QilNode value) { Debug.Assert(inUse, "Reset() wasn't called"); if (value != null) { Debug.Assert(value.XmlType.TypeCode == XmlTypeCode.String); if (value.NodeType == QilNodeType.LiteralString) { builder.Append((string)(QilLiteral)value); } else { FlushBuilder(); concat.Add(value); } } } public QilNode ToQil() { Debug.Assert(inUse); // If we want allow multiple calls to ToQil() this logic should be changed inUse = false; if (concat == null) { return f.String(builder.ToString()); } else { FlushBuilder(); return f.StrConcat(concat); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System.Diagnostics; using System.Xml; using System.Text; using System.Xml.Schema; using System.Xml.Xsl.XPath; using System.Xml.Xsl.Qil; namespace System.Xml.Xsl.Xslt { internal class QilStrConcatenator { private XPathQilFactory f; private StringBuilder builder; private QilList concat; private bool inUse = false; public QilStrConcatenator(XPathQilFactory f) { this.f = f; builder = new StringBuilder(); } public void Reset() { Debug.Assert(! inUse); inUse = true; builder.Length = 0; concat = null; } private void FlushBuilder() { if (concat == null) { concat = f.BaseFactory.Sequence(); } if (builder.Length != 0) { concat.Add(f.String(builder.ToString())); builder.Length = 0; } } public void Append(string value) { Debug.Assert(inUse, "Reset() wasn't called"); builder.Append(value); } public void Append(char value) { Debug.Assert(inUse, "Reset() wasn't called"); builder.Append(value); } public void Append(QilNode value) { Debug.Assert(inUse, "Reset() wasn't called"); if (value != null) { Debug.Assert(value.XmlType.TypeCode == XmlTypeCode.String); if (value.NodeType == QilNodeType.LiteralString) { builder.Append((string)(QilLiteral)value); } else { FlushBuilder(); concat.Add(value); } } } public QilNode ToQil() { Debug.Assert(inUse); // If we want allow multiple calls to ToQil() this logic should be changed inUse = false; if (concat == null) { return f.String(builder.ToString()); } else { FlushBuilder(); return f.StrConcat(concat); } } } } // 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
- _ListenerRequestStream.cs
- XsdValidatingReader.cs
- HostedElements.cs
- SqlRewriteScalarSubqueries.cs
- TypeExtension.cs
- EncryptedPackage.cs
- EntityProviderServices.cs
- XpsSerializationManager.cs
- MobileControlsSection.cs
- NameValuePermission.cs
- SqlColumnizer.cs
- FixedTextContainer.cs
- SplitterCancelEvent.cs
- DrawingServices.cs
- GetWinFXPath.cs
- DesignerObject.cs
- CodeDelegateInvokeExpression.cs
- Attributes.cs
- XmlAttributeProperties.cs
- ViewSimplifier.cs
- XmlMtomReader.cs
- SpellCheck.cs
- SchemaSetCompiler.cs
- CollectionViewProxy.cs
- CompoundFileReference.cs
- dbdatarecord.cs
- ObjectStateFormatter.cs
- TrustManagerPromptUI.cs
- PenCursorManager.cs
- OracleConnectionFactory.cs
- DbConnectionPoolGroup.cs
- OutOfProcStateClientManager.cs
- InstanceKey.cs
- Graphics.cs
- SystemMulticastIPAddressInformation.cs
- PartialCachingControl.cs
- HMACSHA512.cs
- LinkArea.cs
- MemberExpression.cs
- TimelineGroup.cs
- FormClosingEvent.cs
- LineServicesRun.cs
- EmbeddedObject.cs
- FieldMetadata.cs
- CmsUtils.cs
- TextComposition.cs
- HttpHandlersInstallComponent.cs
- util.cs
- NameNode.cs
- RuleRef.cs
- SqlDataRecord.cs
- NamedObject.cs
- PropertyEmitterBase.cs
- WorkflowApplicationUnloadedException.cs
- TypeExtensionConverter.cs
- CodeRegionDirective.cs
- TaskExceptionHolder.cs
- TreeView.cs
- DeploymentSectionCache.cs
- TagMapInfo.cs
- TypeConverterAttribute.cs
- RootAction.cs
- TrustLevelCollection.cs
- IisTraceListener.cs
- BatchParser.cs
- CellParaClient.cs
- FileUpload.cs
- XmlILTrace.cs
- input.cs
- QueryOutputWriter.cs
- CompositeFontFamily.cs
- SerialReceived.cs
- userdatakeys.cs
- CfgArc.cs
- TickBar.cs
- Attributes.cs
- InternalSafeNativeMethods.cs
- BitSet.cs
- DataGridViewRowEventArgs.cs
- XmlReader.cs
- FixedSOMLineCollection.cs
- ItemCollection.cs
- XmlBinaryReaderSession.cs
- DrawingAttributesDefaultValueFactory.cs
- ItemsControlAutomationPeer.cs
- WebBrowserHelper.cs
- ChangeTracker.cs
- HandlerMappingMemo.cs
- CompilerResults.cs
- NativeCppClassAttribute.cs
- EllipseGeometry.cs
- SerializationFieldInfo.cs
- ProcessHostConfigUtils.cs
- GatewayIPAddressInformationCollection.cs
- InputScopeNameConverter.cs
- ELinqQueryState.cs
- Table.cs
- InheritanceContextChangedEventManager.cs
- IDispatchConstantAttribute.cs
- AsymmetricKeyExchangeDeformatter.cs