Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / XmlUtils / System / Xml / Xsl / Runtime / XmlSortKeyAccumulator.cs / 1 / XmlSortKeyAccumulator.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Globalization;
using System.ComponentModel;
namespace System.Xml.Xsl.Runtime {
///
/// Accumulates a list of sort keys and stores them in an array.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public struct XmlSortKeyAccumulator {
private XmlSortKey[] keys;
private int pos;
#if DEBUG
private const int DefaultSortKeyCount = 4;
#else
private const int DefaultSortKeyCount = 64;
#endif
///
/// Initialize the XmlSortKeyAccumulator.
///
public void Create() {
if (this.keys == null)
this.keys = new XmlSortKey[DefaultSortKeyCount];
this.pos = 0;
this.keys[0] = null;
}
///
/// Create a new sort key and append it to the current run of sort keys.
///
public void AddStringSortKey(XmlCollation collation, string value) {
AppendSortKey(collation.CreateSortKey(value));
}
public void AddDecimalSortKey(XmlCollation collation, decimal value) {
AppendSortKey(new XmlDecimalSortKey(value, collation));
}
public void AddIntegerSortKey(XmlCollation collation, long value) {
AppendSortKey(new XmlIntegerSortKey(value, collation));
}
public void AddIntSortKey(XmlCollation collation, int value) {
AppendSortKey(new XmlIntSortKey(value, collation));
}
public void AddDoubleSortKey(XmlCollation collation, double value) {
AppendSortKey(new XmlDoubleSortKey(value, collation));
}
public void AddDateTimeSortKey(XmlCollation collation, DateTime value) {
AppendSortKey(new XmlDateTimeSortKey(value, collation));
}
public void AddEmptySortKey(XmlCollation collation) {
AppendSortKey(new XmlEmptySortKey(collation));
}
///
/// Finish creating the current run of sort keys and begin a new run.
///
public void FinishSortKeys() {
this.pos++;
if (this.pos >= this.keys.Length) {
XmlSortKey[] keysNew = new XmlSortKey[this.pos * 2];
Array.Copy(this.keys, 0, keysNew, 0, this.keys.Length);
this.keys = keysNew;
}
this.keys[this.pos] = null;
}
///
/// Append new sort key to the current run of sort keys.
///
private void AppendSortKey(XmlSortKey key) {
// Ensure that sort will be stable by setting index of key
key.Priority = this.pos;
if (this.keys[this.pos] == null)
this.keys[this.pos] = key;
else
this.keys[this.pos].AddSortKey(key);
}
///
/// Get array of sort keys that was constructed by this internal class.
///
public Array Keys {
get { return this.keys; }
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Globalization;
using System.ComponentModel;
namespace System.Xml.Xsl.Runtime {
///
/// Accumulates a list of sort keys and stores them in an array.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public struct XmlSortKeyAccumulator {
private XmlSortKey[] keys;
private int pos;
#if DEBUG
private const int DefaultSortKeyCount = 4;
#else
private const int DefaultSortKeyCount = 64;
#endif
///
/// Initialize the XmlSortKeyAccumulator.
///
public void Create() {
if (this.keys == null)
this.keys = new XmlSortKey[DefaultSortKeyCount];
this.pos = 0;
this.keys[0] = null;
}
///
/// Create a new sort key and append it to the current run of sort keys.
///
public void AddStringSortKey(XmlCollation collation, string value) {
AppendSortKey(collation.CreateSortKey(value));
}
public void AddDecimalSortKey(XmlCollation collation, decimal value) {
AppendSortKey(new XmlDecimalSortKey(value, collation));
}
public void AddIntegerSortKey(XmlCollation collation, long value) {
AppendSortKey(new XmlIntegerSortKey(value, collation));
}
public void AddIntSortKey(XmlCollation collation, int value) {
AppendSortKey(new XmlIntSortKey(value, collation));
}
public void AddDoubleSortKey(XmlCollation collation, double value) {
AppendSortKey(new XmlDoubleSortKey(value, collation));
}
public void AddDateTimeSortKey(XmlCollation collation, DateTime value) {
AppendSortKey(new XmlDateTimeSortKey(value, collation));
}
public void AddEmptySortKey(XmlCollation collation) {
AppendSortKey(new XmlEmptySortKey(collation));
}
///
/// Finish creating the current run of sort keys and begin a new run.
///
public void FinishSortKeys() {
this.pos++;
if (this.pos >= this.keys.Length) {
XmlSortKey[] keysNew = new XmlSortKey[this.pos * 2];
Array.Copy(this.keys, 0, keysNew, 0, this.keys.Length);
this.keys = keysNew;
}
this.keys[this.pos] = null;
}
///
/// Append new sort key to the current run of sort keys.
///
private void AppendSortKey(XmlSortKey key) {
// Ensure that sort will be stable by setting index of key
key.Priority = this.pos;
if (this.keys[this.pos] == null)
this.keys[this.pos] = key;
else
this.keys[this.pos].AddSortKey(key);
}
///
/// Get array of sort keys that was constructed by this internal class.
///
public Array Keys {
get { return this.keys; }
}
}
}
// 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
- GridView.cs
- DbParameterHelper.cs
- HtmlLinkAdapter.cs
- RuntimeCompatibilityAttribute.cs
- Util.cs
- CqlWriter.cs
- XmlFormatReaderGenerator.cs
- Window.cs
- StringWriter.cs
- HttpInputStream.cs
- _BasicClient.cs
- IIS7UserPrincipal.cs
- InstanceDataCollection.cs
- DecimalKeyFrameCollection.cs
- ControlParameter.cs
- Win32.cs
- PostBackOptions.cs
- XmlTextReaderImplHelpers.cs
- SubMenuStyle.cs
- BevelBitmapEffect.cs
- EntityCommandDefinition.cs
- Quaternion.cs
- StickyNoteContentControl.cs
- CipherData.cs
- HtmlWindowCollection.cs
- SessionEndingEventArgs.cs
- ITextView.cs
- TrustLevel.cs
- OutputScopeManager.cs
- ItemsChangedEventArgs.cs
- DBConnectionString.cs
- RegionInfo.cs
- EmptyCollection.cs
- OracleConnection.cs
- RectAnimationBase.cs
- Int32AnimationUsingKeyFrames.cs
- validationstate.cs
- DataGridViewCellStyleChangedEventArgs.cs
- PersistChildrenAttribute.cs
- SQLByte.cs
- SoapFault.cs
- HtmlMeta.cs
- WebSysDisplayNameAttribute.cs
- PeerEndPoint.cs
- PartialTrustHelpers.cs
- ComponentDesigner.cs
- ThreadExceptionEvent.cs
- loginstatus.cs
- ConcurrentBag.cs
- DocumentSchemaValidator.cs
- DataGridViewRowPrePaintEventArgs.cs
- OfTypeExpression.cs
- ToolStripDropDownClosedEventArgs.cs
- ApplicationHost.cs
- Utils.cs
- HttpResponseHeader.cs
- SamlSecurityTokenAuthenticator.cs
- Function.cs
- ScriptModule.cs
- DataMemberFieldConverter.cs
- CancellationState.cs
- Transform3DCollection.cs
- ImageAttributes.cs
- ChineseLunisolarCalendar.cs
- TextEditorThreadLocalStore.cs
- WeakHashtable.cs
- ConfigPathUtility.cs
- Int64Converter.cs
- SafeFileMapViewHandle.cs
- SimpleMailWebEventProvider.cs
- ipaddressinformationcollection.cs
- XmlSchemaSequence.cs
- CommentAction.cs
- XmlToDatasetMap.cs
- RecordConverter.cs
- SQLConvert.cs
- SiteMapHierarchicalDataSourceView.cs
- TypeForwardedToAttribute.cs
- WorkflowInstanceSuspendedRecord.cs
- NonSerializedAttribute.cs
- Repeater.cs
- SystemColors.cs
- PenThreadWorker.cs
- SelectorItemAutomationPeer.cs
- ListItemCollection.cs
- PropagatorResult.cs
- SetStoryboardSpeedRatio.cs
- PropertyMetadata.cs
- unsafenativemethodstextservices.cs
- Rotation3DAnimation.cs
- PointConverter.cs
- ControlParameter.cs
- DeploymentExceptionMapper.cs
- SqlProfileProvider.cs
- SessionPageStateSection.cs
- PagePropertiesChangingEventArgs.cs
- GestureRecognizer.cs
- loginstatus.cs
- ClientUrlResolverWrapper.cs
- ArrayList.cs