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
- GiveFeedbackEventArgs.cs
- CodeAttributeDeclarationCollection.cs
- autovalidator.cs
- MemoryPressure.cs
- EventManager.cs
- RoutedEvent.cs
- ExtentJoinTreeNode.cs
- WebPart.cs
- WebPartConnectionsCancelVerb.cs
- TableMethodGenerator.cs
- ExceptionValidationRule.cs
- RegexCapture.cs
- WmpBitmapDecoder.cs
- ColorKeyFrameCollection.cs
- FileAuthorizationModule.cs
- AccessDataSource.cs
- HttpFileCollectionWrapper.cs
- DbCommandTree.cs
- SamlSecurityToken.cs
- DesignerVerbCollection.cs
- ElementUtil.cs
- KeyEventArgs.cs
- DataGridItemCollection.cs
- TableAdapterManagerMethodGenerator.cs
- OleDbRowUpdatingEvent.cs
- ClickablePoint.cs
- GraphicsPath.cs
- StrokeNodeEnumerator.cs
- IdentitySection.cs
- CodeExpressionStatement.cs
- Menu.cs
- DoubleLinkList.cs
- GZipDecoder.cs
- AttachInfo.cs
- MetaModel.cs
- XmlSchemaObject.cs
- NullableConverter.cs
- FileSystemWatcher.cs
- AmbientLight.cs
- COAUTHINFO.cs
- COM2ComponentEditor.cs
- ExtendedProtectionPolicyElement.cs
- TextSpan.cs
- TableAutomationPeer.cs
- CodeMemberProperty.cs
- UnsafeNativeMethods.cs
- ControlBuilderAttribute.cs
- BlockUIContainer.cs
- XmlValidatingReader.cs
- IERequestCache.cs
- Rect3D.cs
- VisualTreeHelper.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- SimpleTextLine.cs
- SqlNodeAnnotations.cs
- FigureHelper.cs
- XmlNavigatorFilter.cs
- FileSystemWatcher.cs
- CodeGroup.cs
- DataGridTextBoxColumn.cs
- ViewgenGatekeeper.cs
- NamedPipeProcessProtocolHandler.cs
- EditingMode.cs
- DataRow.cs
- SystemInfo.cs
- RootBrowserWindow.cs
- AsyncContentLoadedEventArgs.cs
- ScriptManagerProxy.cs
- AddInServer.cs
- SettingsPropertyValue.cs
- DataGridViewRowPrePaintEventArgs.cs
- TypeDependencyAttribute.cs
- TextModifierScope.cs
- ArgumentNullException.cs
- BitmapEffectInputData.cs
- StringKeyFrameCollection.cs
- DebugViewWriter.cs
- ProcessHostFactoryHelper.cs
- XmlDataSource.cs
- COM2ExtendedUITypeEditor.cs
- IDictionary.cs
- MimeTypeMapper.cs
- FixedSOMElement.cs
- ImportedNamespaceContextItem.cs
- IndexedGlyphRun.cs
- SqlBulkCopy.cs
- RC2CryptoServiceProvider.cs
- FileDialog_Vista_Interop.cs
- DataFieldEditor.cs
- LinkLabelLinkClickedEvent.cs
- EmptyImpersonationContext.cs
- UnsafeNativeMethods.cs
- CacheModeValueSerializer.cs
- StrongNamePublicKeyBlob.cs
- DefaultTextStoreTextComposition.cs
- TypeExtensionConverter.cs
- PageParserFilter.cs
- PostBackTrigger.cs
- MessageSecurityException.cs
- WorkflowServiceBehavior.cs