Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / fx / src / Xml / System / Xml / Dom / DomNameTable.cs / 2 / 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
- StdRegProviderWrapper.cs
- StateMachineSubscriptionManager.cs
- RealizationContext.cs
- Geometry.cs
- CodeLabeledStatement.cs
- MemoryRecordBuffer.cs
- CrossAppDomainChannel.cs
- NamedPipeTransportElement.cs
- IUnknownConstantAttribute.cs
- RIPEMD160Managed.cs
- ImmutableObjectAttribute.cs
- TrailingSpaceComparer.cs
- ColumnReorderedEventArgs.cs
- Label.cs
- NativeRecognizer.cs
- BitmapSourceSafeMILHandle.cs
- MSAAWinEventWrap.cs
- ProcessHost.cs
- IdentityHolder.cs
- StorageConditionPropertyMapping.cs
- EventWaitHandleSecurity.cs
- BinaryMethodMessage.cs
- StackBuilderSink.cs
- DbProviderConfigurationHandler.cs
- OpenCollectionAsyncResult.cs
- PanelStyle.cs
- JoinElimination.cs
- ProfilePropertySettingsCollection.cs
- XmlSerializationReader.cs
- FullTrustAssemblyCollection.cs
- MethodBody.cs
- TypedDataSetSchemaImporterExtensionFx35.cs
- Dynamic.cs
- CodeNamespaceImportCollection.cs
- PropertyConverter.cs
- CodeExpressionStatement.cs
- CodeTypeParameter.cs
- EventHandlerList.cs
- DeclarativeCatalogPart.cs
- Base64Stream.cs
- BufferBuilder.cs
- ElementAction.cs
- TemplateControl.cs
- HMACSHA384.cs
- XmlSerializerSection.cs
- DataIdProcessor.cs
- BamlCollectionHolder.cs
- WebExceptionStatus.cs
- DataServiceConfiguration.cs
- SpeakProgressEventArgs.cs
- Models.cs
- DataSourceHelper.cs
- Pointer.cs
- ObjectTypeMapping.cs
- ListViewHitTestInfo.cs
- ResourceExpressionBuilder.cs
- ObjectList.cs
- NameValueCollection.cs
- VersionedStream.cs
- ParallelRangeManager.cs
- FlowLayout.cs
- ComponentEvent.cs
- SwitchElementsCollection.cs
- StorageEntitySetMapping.cs
- FixedSOMGroup.cs
- BindingListCollectionView.cs
- BrowserCapabilitiesFactory.cs
- RsaSecurityTokenParameters.cs
- EntityProviderServices.cs
- FilterElement.cs
- OdbcTransaction.cs
- QilReplaceVisitor.cs
- Expressions.cs
- DynamicObject.cs
- KnownBoxes.cs
- EditingCommands.cs
- XPathSelectionIterator.cs
- WebPartManagerInternals.cs
- RemotingConfigParser.cs
- StructuredTypeEmitter.cs
- RuntimeConfigurationRecord.cs
- GroupBoxAutomationPeer.cs
- DrawingGroup.cs
- Char.cs
- NotificationContext.cs
- QueryInterceptorAttribute.cs
- FlowLayoutSettings.cs
- _ChunkParse.cs
- SemaphoreFullException.cs
- ResourceWriter.cs
- ReadOnlyHierarchicalDataSourceView.cs
- ExtractedStateEntry.cs
- SelectedPathEditor.cs
- Sequence.cs
- Freezable.cs
- TextParagraphProperties.cs
- HttpRawResponse.cs
- TableProviderWrapper.cs
- ParameterToken.cs
- RuntimeHandles.cs