Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / Dom / DomNameTable.cs / 1305376 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Converter.cs
- SendKeys.cs
- AVElementHelper.cs
- Rotation3DAnimationBase.cs
- XmlNamedNodeMap.cs
- FixedLineResult.cs
- SafeEventLogWriteHandle.cs
- ToolStripDropDownItemDesigner.cs
- SpeakProgressEventArgs.cs
- Translator.cs
- MasterPageParser.cs
- ReadOnlyPropertyMetadata.cs
- WebPartConnection.cs
- DetailsViewPageEventArgs.cs
- DataObjectSettingDataEventArgs.cs
- ActionItem.cs
- TiffBitmapDecoder.cs
- HiddenFieldPageStatePersister.cs
- Clipboard.cs
- AssociatedControlConverter.cs
- SecurityKeyIdentifierClause.cs
- QilPatternVisitor.cs
- MenuAdapter.cs
- NativeMethods.cs
- QilInvoke.cs
- PromptStyle.cs
- ProcessThread.cs
- InheritanceAttribute.cs
- LayoutTableCell.cs
- XmlObjectSerializerContext.cs
- StringExpressionSet.cs
- Context.cs
- SystemMulticastIPAddressInformation.cs
- ControlCollection.cs
- Cursor.cs
- UInt32Converter.cs
- DropTarget.cs
- ToolStripComboBox.cs
- SafeMemoryMappedFileHandle.cs
- IdentityValidationException.cs
- CheckBoxFlatAdapter.cs
- KerberosSecurityTokenProvider.cs
- TreeViewItem.cs
- BinaryFormatter.cs
- XmlSerializerVersionAttribute.cs
- EditorPartCollection.cs
- FindCriteriaApril2005.cs
- SchemaElement.cs
- SimpleLine.cs
- SqlMetaData.cs
- ServiceContractGenerationContext.cs
- DataSet.cs
- KeyboardEventArgs.cs
- InkCanvasSelection.cs
- wgx_exports.cs
- HyperlinkAutomationPeer.cs
- AbsoluteQuery.cs
- MachineKeyConverter.cs
- CheckPair.cs
- StreamGeometryContext.cs
- PolicyException.cs
- ProtocolsConfigurationEntry.cs
- CheckBoxBaseAdapter.cs
- TemplateControl.cs
- HuffmanTree.cs
- IsolatedStorageFileStream.cs
- BinaryWriter.cs
- PolyBezierSegment.cs
- TypeResolvingOptions.cs
- WindowsIdentity.cs
- XmlArrayAttribute.cs
- PrintControllerWithStatusDialog.cs
- CompModSwitches.cs
- WebException.cs
- WindowsNonControl.cs
- XamlFxTrace.cs
- ISO2022Encoding.cs
- UITypeEditors.cs
- FileCodeGroup.cs
- TheQuery.cs
- DataSourceBooleanViewSchemaConverter.cs
- Expression.cs
- RequestCache.cs
- HttpWriter.cs
- XhtmlConformanceSection.cs
- SessionStateSection.cs
- WizardStepBase.cs
- StatusBarPanel.cs
- Graphics.cs
- AttachInfo.cs
- CmsInterop.cs
- CopyCodeAction.cs
- WebControlsSection.cs
- InputLanguageProfileNotifySink.cs
- ToolStripContainer.cs
- BackStopAuthenticationModule.cs
- ViewService.cs
- SubordinateTransaction.cs
- SqlRewriteScalarSubqueries.cs
- ScalarType.cs