Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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. // //[....] //----------------------------------------------------------------------------- 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PrintPageEvent.cs
- ClearTypeHintValidation.cs
- TransactionContextValidator.cs
- StringFormat.cs
- NonVisualControlAttribute.cs
- TypeHelpers.cs
- EntityDataSourceMemberPath.cs
- NativeCppClassAttribute.cs
- EditCommandColumn.cs
- TreeView.cs
- HtmlInputText.cs
- Vector3DCollection.cs
- GenericTextProperties.cs
- ConstructorNeedsTagAttribute.cs
- NativeActivityFaultContext.cs
- PathTooLongException.cs
- MouseGesture.cs
- InkCanvasFeedbackAdorner.cs
- BlobPersonalizationState.cs
- CompositeFontFamily.cs
- CodeBlockBuilder.cs
- SectionXmlInfo.cs
- TypeHelper.cs
- DataColumnMappingCollection.cs
- SqlClientWrapperSmiStream.cs
- DataGridColumnsPage.cs
- UIPropertyMetadata.cs
- DependentTransaction.cs
- InfiniteIntConverter.cs
- NullableDoubleMinMaxAggregationOperator.cs
- SchemaImporterExtension.cs
- ParenthesizePropertyNameAttribute.cs
- Stacktrace.cs
- AccessDataSourceView.cs
- CategoryGridEntry.cs
- CodeCommentStatement.cs
- ExpressionBindingCollection.cs
- WebPartZoneCollection.cs
- wgx_render.cs
- BamlCollectionHolder.cs
- HostProtectionPermission.cs
- FixedSOMLineRanges.cs
- NavigationPropertyEmitter.cs
- InternalConfigRoot.cs
- ComboBox.cs
- ApplicationDirectory.cs
- TransformerTypeCollection.cs
- PerfCounters.cs
- ConsoleCancelEventArgs.cs
- GeneratedView.cs
- DesignTimeSiteMapProvider.cs
- ResourceManagerWrapper.cs
- EventSinkHelperWriter.cs
- DataTableNewRowEvent.cs
- DataServiceStreamResponse.cs
- PageThemeBuildProvider.cs
- AppSettings.cs
- RootProfilePropertySettingsCollection.cs
- VisualProxy.cs
- HtmlSelect.cs
- SettingsPropertyValueCollection.cs
- DbMetaDataCollectionNames.cs
- oledbmetadatacolumnnames.cs
- ResourceContainer.cs
- ProviderCollection.cs
- ConfigXmlWhitespace.cs
- ListCollectionView.cs
- UIElementCollection.cs
- StatusStrip.cs
- DataRowView.cs
- SequenceFullException.cs
- RequestBringIntoViewEventArgs.cs
- OrderingExpression.cs
- DesignerActionGlyph.cs
- Util.cs
- XmlCountingReader.cs
- DetailsViewDeleteEventArgs.cs
- TransformPatternIdentifiers.cs
- UidManager.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- AlphabetConverter.cs
- FormsIdentity.cs
- HttpServerChannel.cs
- basenumberconverter.cs
- MessageQueueException.cs
- ParameterToken.cs
- MsmqDiagnostics.cs
- StringCollectionEditor.cs
- MenuItemBindingCollection.cs
- PrintSchema.cs
- KeyManager.cs
- BitConverter.cs
- ObjectSpanRewriter.cs
- CheckBox.cs
- Decimal.cs
- FontFamily.cs
- DBBindings.cs
- ListBindingHelper.cs
- SimpleBitVector32.cs
- TransformerConfigurationWizardBase.cs