Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / XmlUtil.cs / 1305376 / XmlUtil.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.IdentityModel { using System.Xml; using System.Diagnostics; static class XmlUtil { public const string XmlNs = "http://www.w3.org/XML/1998/namespace"; public const string XmlNsNs = "http://www.w3.org/2000/xmlns/"; //public static string GetXmlLangAttribute(XmlReader reader) //{ // string xmlLang = null; // if (reader.MoveToAttribute("lang", XmlNs)) // { // xmlLang = reader.Value; // reader.MoveToElement(); // } // if (xmlLang == null) // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.XmlLangAttributeMissing))); // return xmlLang; //} //public static void ReadContentAsQName(XmlReader reader, out string localName, out string ns) //{ // ParseQName(reader, reader.ReadContentAsString(), out localName, out ns); //} public static bool IsWhitespace(char ch) { return (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n'); } public static string TrimEnd(string s) { int i; for (i = s.Length; i > 0 && IsWhitespace(s[i - 1]); i--) ; if (i != s.Length) { return s.Substring(0, i); } return s; } public static string TrimStart(string s) { int i; for (i = 0; i < s.Length && IsWhitespace(s[i]); i++) ; if (i != 0) { return s.Substring(i); } return s; } public static string Trim(string s) { int i; for (i = 0; i < s.Length && IsWhitespace(s[i]); i++); if (i >= s.Length) { return string.Empty; } int j; for (j = s.Length; j > 0 && IsWhitespace(s[j - 1]); j--); DiagnosticUtility.DebugAssert(j > i, "Logic error in XmlUtil.Trim()."); if (i != 0 || j != s.Length) { return s.Substring(i, j - i); } return s; } //public static void ParseQName(XmlReader reader, string qname, out string localName, out string ns) //{ // int index = qname.IndexOf(':'); // string prefix; // if (index < 0) // { // prefix = ""; // localName = TrimStart(TrimEnd(qname)); // } // else // { // if (index == qname.Length - 1) // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidXmlQualifiedName, qname))); // prefix = TrimStart(qname.Substring(0, index)); // localName = TrimEnd(qname.Substring(index + 1)); // } // ns = reader.LookupNamespace(prefix); // if (ns == null) // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.UnboundPrefixInQName, qname))); //} } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.IdentityModel { using System.Xml; using System.Diagnostics; static class XmlUtil { public const string XmlNs = "http://www.w3.org/XML/1998/namespace"; public const string XmlNsNs = "http://www.w3.org/2000/xmlns/"; //public static string GetXmlLangAttribute(XmlReader reader) //{ // string xmlLang = null; // if (reader.MoveToAttribute("lang", XmlNs)) // { // xmlLang = reader.Value; // reader.MoveToElement(); // } // if (xmlLang == null) // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.XmlLangAttributeMissing))); // return xmlLang; //} //public static void ReadContentAsQName(XmlReader reader, out string localName, out string ns) //{ // ParseQName(reader, reader.ReadContentAsString(), out localName, out ns); //} public static bool IsWhitespace(char ch) { return (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n'); } public static string TrimEnd(string s) { int i; for (i = s.Length; i > 0 && IsWhitespace(s[i - 1]); i--) ; if (i != s.Length) { return s.Substring(0, i); } return s; } public static string TrimStart(string s) { int i; for (i = 0; i < s.Length && IsWhitespace(s[i]); i++) ; if (i != 0) { return s.Substring(i); } return s; } public static string Trim(string s) { int i; for (i = 0; i < s.Length && IsWhitespace(s[i]); i++); if (i >= s.Length) { return string.Empty; } int j; for (j = s.Length; j > 0 && IsWhitespace(s[j - 1]); j--); DiagnosticUtility.DebugAssert(j > i, "Logic error in XmlUtil.Trim()."); if (i != 0 || j != s.Length) { return s.Substring(i, j - i); } return s; } //public static void ParseQName(XmlReader reader, string qname, out string localName, out string ns) //{ // int index = qname.IndexOf(':'); // string prefix; // if (index < 0) // { // prefix = ""; // localName = TrimStart(TrimEnd(qname)); // } // else // { // if (index == qname.Length - 1) // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidXmlQualifiedName, qname))); // prefix = TrimStart(qname.Substring(0, index)); // localName = TrimEnd(qname.Substring(index + 1)); // } // ns = reader.LookupNamespace(prefix); // if (ns == null) // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.UnboundPrefixInQName, qname))); //} } } // 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
- StackOverflowException.cs
- TemplateBamlRecordReader.cs
- EmbeddedObject.cs
- SqlException.cs
- MetadataUtilsSmi.cs
- ModelService.cs
- DirectionalLight.cs
- TemplateNodeContextMenu.cs
- PropertyNames.cs
- InvalidDataException.cs
- InheritedPropertyChangedEventArgs.cs
- TextDecorationCollection.cs
- MembershipSection.cs
- IndexingContentUnit.cs
- NotSupportedException.cs
- ToolStripSeparatorRenderEventArgs.cs
- MasterPageParser.cs
- CollectionEditVerbManager.cs
- HttpException.cs
- MetadataPropertyvalue.cs
- ToolStripActionList.cs
- NameTable.cs
- ProxySimple.cs
- DataListComponentEditor.cs
- ConfigurationSettings.cs
- SqlNodeAnnotations.cs
- MsmqTransportReceiveParameters.cs
- HtmlControl.cs
- Model3DGroup.cs
- ContainsRowNumberChecker.cs
- ScrollPattern.cs
- AnnotationStore.cs
- CompositionCommandSet.cs
- Group.cs
- DesignSurfaceEvent.cs
- IISUnsafeMethods.cs
- VectorAnimationUsingKeyFrames.cs
- OperationResponse.cs
- OutputCacheSettingsSection.cs
- ForceCopyBuildProvider.cs
- Msec.cs
- ColorTransform.cs
- SqlClientMetaDataCollectionNames.cs
- PerformanceCounterNameAttribute.cs
- DetailsViewRow.cs
- COM2ExtendedBrowsingHandler.cs
- DataDocumentXPathNavigator.cs
- PropertyGridCommands.cs
- DbConnectionPoolIdentity.cs
- XmlElementAttributes.cs
- ParallelRangeManager.cs
- XmlMemberMapping.cs
- XmlSchemaImporter.cs
- SHA256.cs
- SymDocumentType.cs
- SmtpException.cs
- ForwardPositionQuery.cs
- CodeIterationStatement.cs
- PersonalizationAdministration.cs
- SchemaElementDecl.cs
- DefaultPerformanceCounters.cs
- TextChange.cs
- HandleRef.cs
- TryCatch.cs
- DataGridDetailsPresenter.cs
- DataGridViewCheckBoxColumn.cs
- AutomationInteropProvider.cs
- DATA_BLOB.cs
- XmlCharCheckingWriter.cs
- CodeRegionDirective.cs
- SpoolingTaskBase.cs
- querybuilder.cs
- FileDialog_Vista.cs
- TableStyle.cs
- InputScope.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ItemChangedEventArgs.cs
- StorageBasedPackageProperties.cs
- ISessionStateStore.cs
- ClientFormsAuthenticationCredentials.cs
- Convert.cs
- FromRequest.cs
- ImageDrawing.cs
- EntityCommandDefinition.cs
- PropertyEntry.cs
- HttpCachePolicyWrapper.cs
- SQLUtility.cs
- ImageSource.cs
- UnsafeNativeMethods.cs
- WebService.cs
- UnsafeNativeMethodsMilCoreApi.cs
- SingleConverter.cs
- TcpHostedTransportConfiguration.cs
- LineInfo.cs
- ContainerControl.cs
- ConfigurationErrorsException.cs
- NativeWindow.cs
- Misc.cs
- BinaryFormatterWriter.cs
- SystemWebCachingSectionGroup.cs