Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Xml / System / Xml / XmlQualifiedName.cs / 1 / XmlQualifiedName.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Xml {
using System.Collections;
using System.Diagnostics;
///
///
/// [To be supplied.]
///
[Serializable]
public class XmlQualifiedName {
string name;
string ns;
[NonSerialized]
Int32 hash;
///
///
/// [To be supplied.]
///
public static readonly XmlQualifiedName Empty = new XmlQualifiedName(string.Empty);
///
///
/// [To be supplied.]
///
public XmlQualifiedName() : this(string.Empty, string.Empty) {}
///
///
/// [To be supplied.]
///
public XmlQualifiedName(string name) : this(name, string.Empty) {}
///
///
/// [To be supplied.]
///
public XmlQualifiedName(string name, string ns) {
this.ns = ns == null ? string.Empty : ns;
this.name = name == null ? string.Empty : name;
}
///
///
/// [To be supplied.]
///
public string Namespace {
get { return ns; }
}
///
///
/// [To be supplied.]
///
public string Name {
get { return name; }
}
///
///
/// [To be supplied.]
///
public override int GetHashCode() {
if(hash == 0) {
hash = Name.GetHashCode() /*+ Namespace.GetHashCode()*/; // for perf reasons we are not taking ns's hashcode.
}
return hash;
}
///
///
/// [To be supplied.]
///
public bool IsEmpty {
get { return Name.Length == 0 && Namespace.Length == 0; }
}
///
///
/// [To be supplied.]
///
public override string ToString() {
return Namespace.Length == 0 ? Name : string.Concat(Namespace, ":" , Name);
}
///
///
/// [To be supplied.]
///
public override bool Equals(object other) {
XmlQualifiedName qname;
if ((object) this == other) {
return true;
}
qname = other as XmlQualifiedName;
if (qname != null) {
return (Name == qname.Name && Namespace == qname.Namespace);
}
return false;
}
///
///
/// [To be supplied.]
///
public static bool operator ==(XmlQualifiedName a, XmlQualifiedName b) {
if ((object) a == (object) b)
return true;
if ((object) a == null || (object) b == null)
return false;
return (a.Name == b.Name && a.Namespace == b.Namespace);
}
///
///
/// [To be supplied.]
///
public static bool operator !=(XmlQualifiedName a, XmlQualifiedName b) {
return !(a == b);
}
///
///
/// [To be supplied.]
///
public static string ToString(string name, string ns) {
return ns == null || ns.Length == 0 ? name : ns + ":" + name;
}
// --------- Some useful internal stuff -----------------
internal void Init(string name, string ns) {
Debug.Assert(name != null && ns != null);
this.name = name;
this.ns = ns;
this.hash = 0;
}
internal void SetNamespace(string ns) {
Debug.Assert(ns != null);
this.ns = ns; //Not changing hash since ns is not used to compute hashcode
}
internal void Verify() {
XmlConvert.VerifyNCName(name);
if (ns.Length != 0) {
XmlConvert.ToUri(ns);
}
}
internal void Atomize(XmlNameTable nameTable) {
Debug.Assert(name != null);
name = nameTable.Add(name);
ns = nameTable.Add(ns);
}
internal static XmlQualifiedName Parse(string s, IXmlNamespaceResolver nsmgr, out string prefix) {
string localName;
ValidateNames.ParseQNameThrow(s, out prefix, out localName);
string uri = nsmgr.LookupNamespace(prefix);
if (uri == null) {
if (prefix.Length != 0) {
throw new XmlException(Res.Xml_UnknownNs, prefix);
}
else { //Re-map namespace of empty prefix to string.Empty when there is no default namespace declared
uri = string.Empty;
}
}
return new XmlQualifiedName(localName, uri);
}
internal XmlQualifiedName Clone() {
return (XmlQualifiedName)MemberwiseClone();
}
internal static int Compare(XmlQualifiedName a, XmlQualifiedName b) {
if (null == a) {
return (null == b) ? 0 : -1;
}
if (null == b) {
return 1;
}
int i = String.CompareOrdinal(a.Namespace, b.Namespace);
if (i == 0) {
i = String.CompareOrdinal(a.Name, b.Name);
}
return i;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Xml {
using System.Collections;
using System.Diagnostics;
///
///
/// [To be supplied.]
///
[Serializable]
public class XmlQualifiedName {
string name;
string ns;
[NonSerialized]
Int32 hash;
///
///
/// [To be supplied.]
///
public static readonly XmlQualifiedName Empty = new XmlQualifiedName(string.Empty);
///
///
/// [To be supplied.]
///
public XmlQualifiedName() : this(string.Empty, string.Empty) {}
///
///
/// [To be supplied.]
///
public XmlQualifiedName(string name) : this(name, string.Empty) {}
///
///
/// [To be supplied.]
///
public XmlQualifiedName(string name, string ns) {
this.ns = ns == null ? string.Empty : ns;
this.name = name == null ? string.Empty : name;
}
///
///
/// [To be supplied.]
///
public string Namespace {
get { return ns; }
}
///
///
/// [To be supplied.]
///
public string Name {
get { return name; }
}
///
///
/// [To be supplied.]
///
public override int GetHashCode() {
if(hash == 0) {
hash = Name.GetHashCode() /*+ Namespace.GetHashCode()*/; // for perf reasons we are not taking ns's hashcode.
}
return hash;
}
///
///
/// [To be supplied.]
///
public bool IsEmpty {
get { return Name.Length == 0 && Namespace.Length == 0; }
}
///
///
/// [To be supplied.]
///
public override string ToString() {
return Namespace.Length == 0 ? Name : string.Concat(Namespace, ":" , Name);
}
///
///
/// [To be supplied.]
///
public override bool Equals(object other) {
XmlQualifiedName qname;
if ((object) this == other) {
return true;
}
qname = other as XmlQualifiedName;
if (qname != null) {
return (Name == qname.Name && Namespace == qname.Namespace);
}
return false;
}
///
///
/// [To be supplied.]
///
public static bool operator ==(XmlQualifiedName a, XmlQualifiedName b) {
if ((object) a == (object) b)
return true;
if ((object) a == null || (object) b == null)
return false;
return (a.Name == b.Name && a.Namespace == b.Namespace);
}
///
///
/// [To be supplied.]
///
public static bool operator !=(XmlQualifiedName a, XmlQualifiedName b) {
return !(a == b);
}
///
///
/// [To be supplied.]
///
public static string ToString(string name, string ns) {
return ns == null || ns.Length == 0 ? name : ns + ":" + name;
}
// --------- Some useful internal stuff -----------------
internal void Init(string name, string ns) {
Debug.Assert(name != null && ns != null);
this.name = name;
this.ns = ns;
this.hash = 0;
}
internal void SetNamespace(string ns) {
Debug.Assert(ns != null);
this.ns = ns; //Not changing hash since ns is not used to compute hashcode
}
internal void Verify() {
XmlConvert.VerifyNCName(name);
if (ns.Length != 0) {
XmlConvert.ToUri(ns);
}
}
internal void Atomize(XmlNameTable nameTable) {
Debug.Assert(name != null);
name = nameTable.Add(name);
ns = nameTable.Add(ns);
}
internal static XmlQualifiedName Parse(string s, IXmlNamespaceResolver nsmgr, out string prefix) {
string localName;
ValidateNames.ParseQNameThrow(s, out prefix, out localName);
string uri = nsmgr.LookupNamespace(prefix);
if (uri == null) {
if (prefix.Length != 0) {
throw new XmlException(Res.Xml_UnknownNs, prefix);
}
else { //Re-map namespace of empty prefix to string.Empty when there is no default namespace declared
uri = string.Empty;
}
}
return new XmlQualifiedName(localName, uri);
}
internal XmlQualifiedName Clone() {
return (XmlQualifiedName)MemberwiseClone();
}
internal static int Compare(XmlQualifiedName a, XmlQualifiedName b) {
if (null == a) {
return (null == b) ? 0 : -1;
}
if (null == b) {
return 1;
}
int i = String.CompareOrdinal(a.Namespace, b.Namespace);
if (i == 0) {
i = String.CompareOrdinal(a.Name, b.Name);
}
return i;
}
}
}
// 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
- IResourceProvider.cs
- RadialGradientBrush.cs
- WebPartDescription.cs
- X509CertificateEndpointIdentity.cs
- PowerModeChangedEventArgs.cs
- BaseParser.cs
- MergePropertyDescriptor.cs
- CaseInsensitiveComparer.cs
- DataGridViewCellMouseEventArgs.cs
- ContainerUIElement3D.cs
- HttpWriter.cs
- DropShadowEffect.cs
- EntityDesignPluralizationHandler.cs
- SessionPageStatePersister.cs
- invalidudtexception.cs
- _UriTypeConverter.cs
- ScopeElement.cs
- TargetException.cs
- DocumentOrderQuery.cs
- KoreanCalendar.cs
- DesignTimeParseData.cs
- PropertyBuilder.cs
- DiagnosticsConfiguration.cs
- EventTask.cs
- RelationshipConstraintValidator.cs
- FileAuthorizationModule.cs
- XmlWriterTraceListener.cs
- SystemIPAddressInformation.cs
- LoginDesigner.cs
- DynamicResourceExtension.cs
- SqlProviderServices.cs
- Region.cs
- ExpressionBinding.cs
- ProviderCollection.cs
- TraceSection.cs
- WorkflowOperationInvoker.cs
- ChildChangedEventArgs.cs
- SortQuery.cs
- ListItemCollection.cs
- FunctionMappingTranslator.cs
- PackagingUtilities.cs
- VisemeEventArgs.cs
- AnyReturnReader.cs
- XmlRootAttribute.cs
- DictionaryBase.cs
- MenuTracker.cs
- ClientSettingsProvider.cs
- WindowsEditBoxRange.cs
- OleServicesContext.cs
- ScriptReferenceBase.cs
- SchemeSettingElement.cs
- DbExpressionRules.cs
- ClientBuildManagerCallback.cs
- ProjectionPath.cs
- CaseInsensitiveComparer.cs
- DynamicControlParameter.cs
- ScrollProperties.cs
- NCryptSafeHandles.cs
- DefaultPrintController.cs
- NamespaceEmitter.cs
- FixedLineResult.cs
- CleanUpVirtualizedItemEventArgs.cs
- SqlStream.cs
- TabItemAutomationPeer.cs
- FileDialogCustomPlace.cs
- DoubleLinkListEnumerator.cs
- FlowDocumentFormatter.cs
- HttpErrorTraceRecord.cs
- DiagnosticsConfiguration.cs
- LoadGrammarCompletedEventArgs.cs
- DataObject.cs
- ParameterBinding.cs
- CriticalHandle.cs
- TextReader.cs
- DatatypeImplementation.cs
- Formatter.cs
- MediaScriptCommandRoutedEventArgs.cs
- CheckedListBox.cs
- ListViewItemEventArgs.cs
- LinearGradientBrush.cs
- XmlBinaryWriter.cs
- HttpRequestBase.cs
- IisTraceListener.cs
- ClientRolePrincipal.cs
- ObjectMemberMapping.cs
- selecteditemcollection.cs
- DetailsViewDeleteEventArgs.cs
- OdbcCommandBuilder.cs
- ImmutableCommunicationTimeouts.cs
- XmlSchemaSimpleTypeList.cs
- XmlSchemaGroupRef.cs
- IEnumerable.cs
- Int32Storage.cs
- LocalizabilityAttribute.cs
- SchemaInfo.cs
- PrivateFontCollection.cs
- TypeExtensionSerializer.cs
- RecognitionEventArgs.cs
- SoapAttributeOverrides.cs
- ContextStaticAttribute.cs