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
- ToolBarTray.cs
- UnmanagedMemoryAccessor.cs
- WebPartConnectionsConnectVerb.cs
- ConfigurationFileMap.cs
- ConnectionPointCookie.cs
- RawKeyboardInputReport.cs
- AdvancedBindingEditor.cs
- RepeaterItem.cs
- OleDbMetaDataFactory.cs
- CssTextWriter.cs
- DrawingVisualDrawingContext.cs
- FrugalList.cs
- SerialReceived.cs
- SEHException.cs
- AdPostCacheSubstitution.cs
- AnimationClock.cs
- RenderDataDrawingContext.cs
- DataGridViewControlCollection.cs
- Clause.cs
- ResetableIterator.cs
- CodeAttachEventStatement.cs
- shaperfactoryquerycacheentry.cs
- ReaderWriterLockWrapper.cs
- _OSSOCK.cs
- SchemaNames.cs
- UnsafeNativeMethods.cs
- DebuggerService.cs
- DescendentsWalkerBase.cs
- Compiler.cs
- BinaryExpression.cs
- MenuItemBindingCollection.cs
- CheckBox.cs
- TaskExceptionHolder.cs
- D3DImage.cs
- FamilyMap.cs
- AccessViolationException.cs
- ToolStripRenderEventArgs.cs
- XmlElement.cs
- SyndicationLink.cs
- MachineKeySection.cs
- SpoolingTask.cs
- DataGridLinkButton.cs
- CombinedGeometry.cs
- WindowPattern.cs
- PeerNameRecord.cs
- AsyncResult.cs
- UnitySerializationHolder.cs
- TypeLoadException.cs
- XmlCharacterData.cs
- FlowDocumentPaginator.cs
- TreeNodeClickEventArgs.cs
- NotFiniteNumberException.cs
- PageFunction.cs
- DoubleLink.cs
- HtmlDocument.cs
- SortedList.cs
- ScrollPatternIdentifiers.cs
- ChangesetResponse.cs
- CultureMapper.cs
- ButtonPopupAdapter.cs
- XmlUrlResolver.cs
- CheckBox.cs
- __FastResourceComparer.cs
- LayoutInformation.cs
- DSASignatureFormatter.cs
- MobileControlPersister.cs
- ToolStripDropDownMenu.cs
- DependencyPropertyKind.cs
- XsltArgumentList.cs
- __Filters.cs
- GeometryConverter.cs
- CatalogZoneBase.cs
- RadioButtonStandardAdapter.cs
- SvcMapFile.cs
- SimpleTextLine.cs
- PipelineModuleStepContainer.cs
- ServiceBehaviorAttribute.cs
- PrincipalPermission.cs
- ComponentEvent.cs
- InternalSendMessage.cs
- DecimalFormatter.cs
- EmptyEnumerable.cs
- WeakEventTable.cs
- ColumnHeader.cs
- FormatConvertedBitmap.cs
- ClockGroup.cs
- WebReferenceCollection.cs
- WrappedIUnknown.cs
- SchemaEntity.cs
- SpecialNameAttribute.cs
- ellipse.cs
- DefaultHttpHandler.cs
- RewritingPass.cs
- DataView.cs
- HwndHostAutomationPeer.cs
- CleanUpVirtualizedItemEventArgs.cs
- MediaContextNotificationWindow.cs
- EntityDataSourceEntityTypeFilterItem.cs
- SchemaImporterExtensionsSection.cs
- GradientStopCollection.cs