Code:
/ FX-1434 / FX-1434 / 1.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
- TableLayoutStyleCollection.cs
- ConfigurationSectionCollection.cs
- TypeLibConverter.cs
- BitVector32.cs
- ProcessInputEventArgs.cs
- SiteMap.cs
- ReachFixedPageSerializerAsync.cs
- RemotingConfiguration.cs
- MultipleViewPatternIdentifiers.cs
- XmlIncludeAttribute.cs
- DataGridClipboardHelper.cs
- InvalidCastException.cs
- TransformGroup.cs
- oledbmetadatacolumnnames.cs
- DesignTimeVisibleAttribute.cs
- FocusWithinProperty.cs
- ResourceDictionaryCollection.cs
- Content.cs
- UxThemeWrapper.cs
- TreeNodeStyle.cs
- XmlDataSourceNodeDescriptor.cs
- AutomationPattern.cs
- MetadataItemEmitter.cs
- TransactionFlowAttribute.cs
- PerformanceCounterScope.cs
- InputReferenceExpression.cs
- StreamInfo.cs
- PolicyValidationException.cs
- SmiRequestExecutor.cs
- Processor.cs
- AutoGeneratedFieldProperties.cs
- IDispatchConstantAttribute.cs
- StructuredTypeInfo.cs
- ChannelFactoryBase.cs
- BitStack.cs
- DiscoveryReferences.cs
- DataServiceKeyAttribute.cs
- LinqDataSourceContextEventArgs.cs
- DataGridViewCheckBoxColumn.cs
- UpDownBaseDesigner.cs
- SystemInfo.cs
- MailAddressParser.cs
- SQLInt64.cs
- MsmqEncryptionAlgorithm.cs
- RadioButton.cs
- ReflectionTypeLoadException.cs
- XmlSerializerOperationFormatter.cs
- SchemaAttDef.cs
- CompilationSection.cs
- CacheHelper.cs
- PersonalizationProvider.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- mongolianshape.cs
- TimelineGroup.cs
- SqlDataSourceCache.cs
- ObjectDataSourceChooseTypePanel.cs
- DiagnosticsConfigurationHandler.cs
- BitmapImage.cs
- CustomActivityDesigner.cs
- BasicHttpSecurityElement.cs
- TextCollapsingProperties.cs
- WebPartConnectionsCloseVerb.cs
- Package.cs
- DynamicResourceExtensionConverter.cs
- Automation.cs
- SchemaNotation.cs
- TaskSchedulerException.cs
- Rect.cs
- CompilerTypeWithParams.cs
- XmlILStorageConverter.cs
- MetadataFile.cs
- OdbcUtils.cs
- DataContractSerializerSection.cs
- FontConverter.cs
- LayoutDump.cs
- ToolStripSystemRenderer.cs
- XhtmlBasicSelectionListAdapter.cs
- PropertyChangedEventArgs.cs
- DataGridTextBox.cs
- ResourceExpressionEditorSheet.cs
- AuthenticationSection.cs
- OperationAbortedException.cs
- ResolveCriteria.cs
- EndpointAddress10.cs
- SwitchAttribute.cs
- SystemInformation.cs
- DynamicResourceExtensionConverter.cs
- StringArrayConverter.cs
- Span.cs
- _Rfc2616CacheValidators.cs
- WebServiceEnumData.cs
- AstTree.cs
- AdRotator.cs
- ConfigurationElementProperty.cs
- EdmToObjectNamespaceMap.cs
- InlineCategoriesDocument.cs
- ModelUtilities.cs
- ResourcePermissionBase.cs
- FreezableDefaultValueFactory.cs
- WebPartDisplayModeCollection.cs