Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / XmlUtils / System / Xml / Xsl / Runtime / XmlSortKeyAccumulator.cs / 1305376 / 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
- PieceDirectory.cs
- FormatVersion.cs
- Visual3D.cs
- ReliableChannelFactory.cs
- PresentationAppDomainManager.cs
- BitmapImage.cs
- FastPropertyAccessor.cs
- NetTcpSectionData.cs
- IChannel.cs
- MatrixAnimationUsingPath.cs
- RestClientProxyHandler.cs
- SurrogateEncoder.cs
- TextSelectionHighlightLayer.cs
- CodeVariableReferenceExpression.cs
- SettingsPropertyValueCollection.cs
- HtmlTitle.cs
- XmlText.cs
- Path.cs
- NotImplementedException.cs
- ResourceReferenceExpression.cs
- SqlTypeConverter.cs
- TypeElement.cs
- JsonFormatWriterGenerator.cs
- ErrorWebPart.cs
- PerspectiveCamera.cs
- PresentationAppDomainManager.cs
- Mutex.cs
- DataGridView.cs
- QueryStringParameter.cs
- Geometry.cs
- InProcStateClientManager.cs
- ProfileManager.cs
- counter.cs
- TrackBar.cs
- DoubleAnimationClockResource.cs
- ColorTranslator.cs
- XmlSecureResolver.cs
- XamlDesignerSerializationManager.cs
- WebServiceMethodData.cs
- XmlIncludeAttribute.cs
- InteropAutomationProvider.cs
- WebDescriptionAttribute.cs
- ExpressionBindingCollection.cs
- AttachInfo.cs
- SystemParameters.cs
- TransactionManager.cs
- FunctionDescription.cs
- SqlTriggerContext.cs
- DecoderFallback.cs
- ScriptResourceAttribute.cs
- SemaphoreFullException.cs
- EntityConnectionStringBuilderItem.cs
- Win32MouseDevice.cs
- DiagnosticTraceSource.cs
- Pointer.cs
- LinqDataView.cs
- Point4DValueSerializer.cs
- SamlAudienceRestrictionCondition.cs
- BitmapDecoder.cs
- VirtualPath.cs
- ListViewItem.cs
- XPathNodeList.cs
- NativeStructs.cs
- PageParserFilter.cs
- MaskedTextBox.cs
- SqlDataRecord.cs
- XmlWriterTraceListener.cs
- ComplexBindingPropertiesAttribute.cs
- CustomAttributeFormatException.cs
- CacheModeConverter.cs
- _HeaderInfo.cs
- Cloud.cs
- ByteRangeDownloader.cs
- LightweightCodeGenerator.cs
- DbExpressionRules.cs
- XMLSyntaxException.cs
- AdornerHitTestResult.cs
- FixedStringLookup.cs
- CollectionContainer.cs
- ChangeNode.cs
- ReferenceList.cs
- GlyphInfoList.cs
- SpotLight.cs
- TabletDevice.cs
- Light.cs
- Point.cs
- NativeBuffer.cs
- ProcessModelInfo.cs
- ArgumentFixer.cs
- AttachmentService.cs
- Codec.cs
- CodeMemberMethod.cs
- StringAttributeCollection.cs
- UnsafeNativeMethods.cs
- ListParaClient.cs
- QilStrConcatenator.cs
- VisualBrush.cs
- ModelVisual3D.cs
- EmptyControlCollection.cs
- InlineUIContainer.cs