Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Xml / System / Xml / Dom / DomNameTable.cs / 1 / DomNameTable.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Xml.Schema; namespace System.Xml { internal class DomNameTable { XmlName[] entries; int count; int mask; XmlDocument ownerDocument; XmlNameTable nameTable; const int InitialSize = 64; // must be a power of two public DomNameTable( XmlDocument document ) { ownerDocument = document; nameTable = document.NameTable; entries = new XmlName[InitialSize]; mask = InitialSize - 1; Debug.Assert( ( entries.Length & mask ) == 0 ); // entries.Length must be a power of two } public XmlName GetName(string prefix, string localName, string ns, IXmlSchemaInfo schemaInfo) { if (prefix == null) { prefix = string.Empty; } if (ns == null) { ns = string.Empty; } int hashCode = XmlName.GetHashCode(localName); for (XmlName e = entries[hashCode & mask]; e != null; e = e.next) { if (e.HashCode == hashCode && ((object)e.LocalName == (object)localName || e.LocalName.Equals(localName)) && ((object)e.Prefix == (object)prefix || e.Prefix.Equals(prefix)) && ((object)e.NamespaceURI == (object)ns || e.NamespaceURI.Equals(ns)) && e.Equals(schemaInfo)) { return e; } } return null; } public XmlName AddName(string prefix, string localName, string ns, IXmlSchemaInfo schemaInfo) { if (prefix == null) { prefix = string.Empty; } if (ns == null) { ns = string.Empty; } int hashCode = XmlName.GetHashCode(localName); for (XmlName e = entries[hashCode & mask]; e != null; e = e.next) { if (e.HashCode == hashCode && ((object)e.LocalName == (object)localName || e.LocalName.Equals(localName)) && ((object)e.Prefix == (object)prefix || e.Prefix.Equals(prefix)) && ((object)e.NamespaceURI == (object)ns || e.NamespaceURI.Equals(ns)) && e.Equals(schemaInfo)) { return e; } } prefix = nameTable.Add(prefix); localName = nameTable.Add(localName); ns = nameTable.Add(ns); int index = hashCode & mask; XmlName name = XmlName.Create(prefix, localName, ns, hashCode, ownerDocument, entries[index], schemaInfo); entries[index] = name; if (count++ == mask) { Grow(); } return name; } private void Grow() { int newMask = mask * 2 + 1; XmlName[] oldEntries = entries; XmlName[] newEntries = new XmlName[newMask+1]; // use oldEntries.Length to eliminate the rangecheck for ( int i = 0; i < oldEntries.Length; i++ ) { XmlName name = oldEntries[i]; while ( name != null ) { int newIndex = name.HashCode & newMask; XmlName tmp = name.next; name.next = newEntries[newIndex]; newEntries[newIndex] = name; name = tmp; } } entries = newEntries; mask = newMask; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InteropAutomationProvider.cs
- Hex.cs
- NumberSubstitution.cs
- DbMetaDataFactory.cs
- TableLayoutStyle.cs
- NumericUpDownAcceleration.cs
- SqlConnectionStringBuilder.cs
- StylusButtonEventArgs.cs
- StyleTypedPropertyAttribute.cs
- UnsafeNativeMethods.cs
- LinqMaximalSubtreeNominator.cs
- SmtpMail.cs
- ScrollableControl.cs
- CryptoStream.cs
- WebConvert.cs
- Ipv6Element.cs
- SimpleApplicationHost.cs
- DrawingImage.cs
- CatalogPart.cs
- GridViewPageEventArgs.cs
- DataGridViewRow.cs
- InputBinder.cs
- Simplifier.cs
- ImageDrawing.cs
- CodeDomConfigurationHandler.cs
- BmpBitmapDecoder.cs
- DefaultBinder.cs
- CustomAttribute.cs
- SkipStoryboardToFill.cs
- SqlFactory.cs
- BoundingRectTracker.cs
- WorkflowPrinting.cs
- DateTimeSerializationSection.cs
- MarshalByRefObject.cs
- _SslSessionsCache.cs
- HMAC.cs
- ListViewDeletedEventArgs.cs
- Condition.cs
- StylusPointProperties.cs
- IERequestCache.cs
- ObjectStateEntryDbDataRecord.cs
- DispatchWrapper.cs
- QualifiedCellIdBoolean.cs
- SystemWebExtensionsSectionGroup.cs
- TreeViewItem.cs
- MonthChangedEventArgs.cs
- TextTreeTextBlock.cs
- StreamGeometry.cs
- RegexCaptureCollection.cs
- MessageDesigner.cs
- MDIWindowDialog.cs
- HtmlElementErrorEventArgs.cs
- Command.cs
- XMLUtil.cs
- TypeDescriptionProviderAttribute.cs
- Thread.cs
- PropertyManager.cs
- WebPartTransformerAttribute.cs
- XPathSelfQuery.cs
- ThreadInterruptedException.cs
- WorkflowOperationBehavior.cs
- TreeIterator.cs
- PropertyIdentifier.cs
- DesignerTransaction.cs
- DrawingCollection.cs
- TableItemPatternIdentifiers.cs
- IssuanceTokenProviderState.cs
- XmlSchemaComplexContentExtension.cs
- Table.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- SerialReceived.cs
- CommonProperties.cs
- BatchWriter.cs
- CryptoKeySecurity.cs
- SettingsBindableAttribute.cs
- CancellationTokenSource.cs
- EventLogEntryCollection.cs
- ISAPIRuntime.cs
- PropertyPathConverter.cs
- Application.cs
- InputEventArgs.cs
- TextModifierScope.cs
- HtmlWindowCollection.cs
- AuthenticationModuleElement.cs
- XdrBuilder.cs
- SwitchAttribute.cs
- InvalidAsynchronousStateException.cs
- BuildProviderAppliesToAttribute.cs
- LinkClickEvent.cs
- AnimationLayer.cs
- TabControlToolboxItem.cs
- DataBoundControlAdapter.cs
- SpinLock.cs
- SmiRecordBuffer.cs
- ShapeTypeface.cs
- LogRestartAreaEnumerator.cs
- BookmarkOptionsHelper.cs
- AutomationTextAttribute.cs
- BaseTemplateCodeDomTreeGenerator.cs
- AbstractExpressions.cs