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
- ExpressionContext.cs
- ListViewDeletedEventArgs.cs
- PropertyChangingEventArgs.cs
- Matrix.cs
- PeerIPHelper.cs
- JumpItem.cs
- RowTypePropertyElement.cs
- LayoutEngine.cs
- FixedSOMPageElement.cs
- PeerApplication.cs
- AppDomainShutdownMonitor.cs
- ControlEvent.cs
- DataServiceQueryOfT.cs
- CustomValidator.cs
- HandlerBase.cs
- ToolStripPanelRenderEventArgs.cs
- CodePropertyReferenceExpression.cs
- UIElementHelper.cs
- TextEditorCharacters.cs
- RegisteredArrayDeclaration.cs
- WebPartConnectVerb.cs
- DataServiceKeyAttribute.cs
- DivideByZeroException.cs
- ResourceAssociationSetEnd.cs
- Inflater.cs
- validationstate.cs
- DocumentManager.cs
- SqlSupersetValidator.cs
- MetadataWorkspace.cs
- ActiveXHelper.cs
- TileBrush.cs
- HostedNamedPipeTransportManager.cs
- MaskedTextBox.cs
- SecurityRuntime.cs
- ScrollViewer.cs
- WindowsStartMenu.cs
- odbcmetadatacollectionnames.cs
- ExpressionEditor.cs
- DictionaryManager.cs
- RegexGroupCollection.cs
- Rectangle.cs
- X509Certificate.cs
- BamlLocalizationDictionary.cs
- Util.cs
- EventWaitHandle.cs
- DynamicField.cs
- RootBrowserWindowProxy.cs
- NullExtension.cs
- RoleGroup.cs
- SchemaElementLookUpTable.cs
- FileLevelControlBuilderAttribute.cs
- SmiEventSink_Default.cs
- SqlSupersetValidator.cs
- WorkflowServiceHost.cs
- NativeStructs.cs
- LineServicesRun.cs
- SHA512Managed.cs
- SystemIPv6InterfaceProperties.cs
- XmlNodeWriter.cs
- CodeThrowExceptionStatement.cs
- Property.cs
- ComplexBindingPropertiesAttribute.cs
- DataGridBoolColumn.cs
- ACL.cs
- WebPartMovingEventArgs.cs
- View.cs
- SqlDataSourceView.cs
- Completion.cs
- ReferentialConstraint.cs
- HtmlProps.cs
- SecureUICommand.cs
- HttpConfigurationContext.cs
- AutomationPatternInfo.cs
- SqlInternalConnection.cs
- ColorMap.cs
- ParseNumbers.cs
- OciEnlistContext.cs
- Highlights.cs
- WebPartVerb.cs
- precedingquery.cs
- MultilineStringConverter.cs
- ComponentRenameEvent.cs
- TextEffect.cs
- DiscriminatorMap.cs
- SmiRequestExecutor.cs
- ConfigXmlCDataSection.cs
- DbConnectionHelper.cs
- Exceptions.cs
- DataRecordObjectView.cs
- SmtpClient.cs
- DetailsViewInsertedEventArgs.cs
- MultiPropertyDescriptorGridEntry.cs
- ConfigUtil.cs
- DefaultSettingsSection.cs
- SQLSingle.cs
- ListBox.cs
- SmiEventStream.cs
- ProxyElement.cs
- PerspectiveCamera.cs
- Popup.cs