Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / Serialization / NameTable.cs / 1305376 / NameTable.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Xml.Serialization {
using System.Collections;
internal class NameKey {
string ns;
string name;
internal NameKey(string name, string ns) {
this.name = name;
this.ns = ns;
}
public override bool Equals(object other) {
if (!(other is NameKey)) return false;
NameKey key = (NameKey)other;
return name == key.name && ns == key.ns;
}
public override int GetHashCode() {
return (ns == null ? "".GetHashCode() : ns.GetHashCode()) ^ (name == null ? 0 : name.GetHashCode());
}
}
internal interface INameScope {
object this[string name, string ns] {get; set;}
}
internal class NameTable : INameScope {
Hashtable table = new Hashtable();
internal void Add(XmlQualifiedName qname, object value) {
Add(qname.Name, qname.Namespace, value);
}
internal void Add(string name, string ns, object value) {
NameKey key = new NameKey(name, ns);
table.Add(key, value);
}
internal object this[XmlQualifiedName qname] {
get {
return table[new NameKey(qname.Name, qname.Namespace)];
}
set {
table[new NameKey(qname.Name, qname.Namespace)] = value;
}
}
internal object this[string name, string ns] {
get {
return table[new NameKey(name, ns)];
}
set {
table[new NameKey(name, ns)] = value;
}
}
object INameScope.this[string name, string ns] {
get {
return table[new NameKey(name, ns)];
}
set {
table[new NameKey(name, ns)] = value;
}
}
internal ICollection Values {
get { return table.Values; }
}
internal Array ToArray(Type type) {
Array a = Array.CreateInstance(type, table.Count);
table.Values.CopyTo(a, 0);
return a;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Xml.Serialization {
using System.Collections;
internal class NameKey {
string ns;
string name;
internal NameKey(string name, string ns) {
this.name = name;
this.ns = ns;
}
public override bool Equals(object other) {
if (!(other is NameKey)) return false;
NameKey key = (NameKey)other;
return name == key.name && ns == key.ns;
}
public override int GetHashCode() {
return (ns == null ? "".GetHashCode() : ns.GetHashCode()) ^ (name == null ? 0 : name.GetHashCode());
}
}
internal interface INameScope {
object this[string name, string ns] {get; set;}
}
internal class NameTable : INameScope {
Hashtable table = new Hashtable();
internal void Add(XmlQualifiedName qname, object value) {
Add(qname.Name, qname.Namespace, value);
}
internal void Add(string name, string ns, object value) {
NameKey key = new NameKey(name, ns);
table.Add(key, value);
}
internal object this[XmlQualifiedName qname] {
get {
return table[new NameKey(qname.Name, qname.Namespace)];
}
set {
table[new NameKey(qname.Name, qname.Namespace)] = value;
}
}
internal object this[string name, string ns] {
get {
return table[new NameKey(name, ns)];
}
set {
table[new NameKey(name, ns)] = value;
}
}
object INameScope.this[string name, string ns] {
get {
return table[new NameKey(name, ns)];
}
set {
table[new NameKey(name, ns)] = value;
}
}
internal ICollection Values {
get { return table.Values; }
}
internal Array ToArray(Type type) {
Array a = Array.CreateInstance(type, table.Count);
table.Values.CopyTo(a, 0);
return a;
}
}
}
// 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
- ImageConverter.cs
- SweepDirectionValidation.cs
- DynamicILGenerator.cs
- MSHTMLHostUtil.cs
- Trace.cs
- KoreanCalendar.cs
- MinimizableAttributeTypeConverter.cs
- Stream.cs
- NotifyCollectionChangedEventArgs.cs
- SQLByte.cs
- IPEndPointCollection.cs
- ToolStripComboBox.cs
- Label.cs
- AutomationEventArgs.cs
- CodeExporter.cs
- XmlSchemaAppInfo.cs
- StylusPointProperty.cs
- CodeDelegateInvokeExpression.cs
- ComPlusTypeLoader.cs
- ManualResetEventSlim.cs
- OpenFileDialog.cs
- CursorEditor.cs
- SettingsContext.cs
- HandleCollector.cs
- CompareValidator.cs
- CompositeActivityMarkupSerializer.cs
- StyleTypedPropertyAttribute.cs
- CompilationRelaxations.cs
- UiaCoreProviderApi.cs
- MDIWindowDialog.cs
- TargetParameterCountException.cs
- ModelFunctionTypeElement.cs
- SortAction.cs
- InputMethodStateTypeInfo.cs
- SharedStatics.cs
- BrushValueSerializer.cs
- InvalidPropValue.cs
- StyleModeStack.cs
- SessionEndedEventArgs.cs
- MimeTypePropertyAttribute.cs
- ByteFacetDescriptionElement.cs
- CreateUserWizard.cs
- BitmapCache.cs
- RenderOptions.cs
- Activator.cs
- DbInsertCommandTree.cs
- XmlSerializerVersionAttribute.cs
- DodSequenceMerge.cs
- EntityContainerEmitter.cs
- ClientRuntimeConfig.cs
- DEREncoding.cs
- SystemWebExtensionsSectionGroup.cs
- PageRouteHandler.cs
- CapabilitiesPattern.cs
- HostProtectionException.cs
- WebControlAdapter.cs
- SmtpSection.cs
- SuppressMessageAttribute.cs
- ListItemCollection.cs
- HttpCachePolicy.cs
- Win32NamedPipes.cs
- Root.cs
- Polygon.cs
- MouseEventArgs.cs
- DefaultPerformanceCounters.cs
- ErrorWrapper.cs
- ChtmlTextWriter.cs
- LineServices.cs
- IIS7UserPrincipal.cs
- RenderingBiasValidation.cs
- HtmlElementErrorEventArgs.cs
- DataGridViewCell.cs
- AssemblyCache.cs
- NavigatingCancelEventArgs.cs
- ScrollBar.cs
- MatrixIndependentAnimationStorage.cs
- Operator.cs
- OutOfMemoryException.cs
- WindowAutomationPeer.cs
- FileDialogCustomPlaces.cs
- TextEditorTyping.cs
- IChannel.cs
- ThreadPool.cs
- Wizard.cs
- CurrencyManager.cs
- ArithmeticLiteral.cs
- Zone.cs
- ReadOnlyHierarchicalDataSource.cs
- PolyBezierSegment.cs
- ProgressChangedEventArgs.cs
- DataProtection.cs
- PromptEventArgs.cs
- SmtpTransport.cs
- PlainXmlDeserializer.cs
- ImageFormatConverter.cs
- EditableRegion.cs
- TaskFactory.cs
- ScriptDescriptor.cs
- DataQuery.cs
- OdbcCommand.cs