Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ProcessHostFactoryHelper.cs
- BooleanSwitch.cs
- DrawingState.cs
- Graph.cs
- DtrList.cs
- OdbcHandle.cs
- XmlIgnoreAttribute.cs
- SystemTcpStatistics.cs
- DataComponentGenerator.cs
- ChannelManager.cs
- Tablet.cs
- SemaphoreSecurity.cs
- SQLDouble.cs
- EntityConnectionStringBuilderItem.cs
- EntryPointNotFoundException.cs
- CultureData.cs
- CodeThrowExceptionStatement.cs
- SecureEnvironment.cs
- HtmlInputHidden.cs
- OrderByLifter.cs
- ErrorHandler.cs
- DialogResultConverter.cs
- MultiBinding.cs
- PropertyEmitter.cs
- SimpleFileLog.cs
- OperationExecutionFault.cs
- XamlWrappingReader.cs
- CalculatedColumn.cs
- DataContractSerializerMessageContractImporter.cs
- SmtpLoginAuthenticationModule.cs
- XmlSerializableReader.cs
- VirtualizedCellInfoCollection.cs
- RSAPKCS1SignatureFormatter.cs
- ChannelProtectionRequirements.cs
- EnumConverter.cs
- WebInvokeAttribute.cs
- ImageList.cs
- SqlFacetAttribute.cs
- MediaPlayer.cs
- InfoCardTraceRecord.cs
- TextEncodedRawTextWriter.cs
- ParamArrayAttribute.cs
- GroupItemAutomationPeer.cs
- TreeViewBindingsEditor.cs
- FacetEnabledSchemaElement.cs
- QuaternionKeyFrameCollection.cs
- XmlDataSourceNodeDescriptor.cs
- DrawItemEvent.cs
- Path.cs
- CheckedPointers.cs
- SystemEvents.cs
- RegexWriter.cs
- LinqDataView.cs
- Codec.cs
- recordstatefactory.cs
- ElementFactory.cs
- XmlSchemaObjectCollection.cs
- RangeEnumerable.cs
- DBDataPermissionAttribute.cs
- ConfigurationPermission.cs
- UserControlAutomationPeer.cs
- ILGenerator.cs
- InvalidEnumArgumentException.cs
- HTMLTextWriter.cs
- Separator.cs
- SymbolUsageManager.cs
- CollectionConverter.cs
- versioninfo.cs
- TransactionProtocol.cs
- TreeBuilderBamlTranslator.cs
- MetadataCache.cs
- ObservableDictionary.cs
- Point.cs
- MetabaseServerConfig.cs
- WebPartMinimizeVerb.cs
- SafeRightsManagementQueryHandle.cs
- SetStoryboardSpeedRatio.cs
- XmlAttribute.cs
- XdrBuilder.cs
- PathStreamGeometryContext.cs
- RowToFieldTransformer.cs
- XmlComplianceUtil.cs
- FileFormatException.cs
- Primitive.cs
- SqlDataReader.cs
- TypeInfo.cs
- FacetEnabledSchemaElement.cs
- PrtTicket_Public.cs
- UTF7Encoding.cs
- XmlNamespaceMappingCollection.cs
- LoadedOrUnloadedOperation.cs
- FormViewDeletedEventArgs.cs
- SrgsNameValueTag.cs
- VectorAnimation.cs
- AutomationEventArgs.cs
- VisualStateManager.cs
- HttpRuntimeSection.cs
- glyphs.cs
- safesecurityhelperavalon.cs
- Constraint.cs