Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / XmlUtil.cs / 1 / XmlUtil.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel
{
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;
}
// FIX for 7455
public static bool IsTrue(string booleanValue)
{
if (string.IsNullOrEmpty(booleanValue))
{
return false;
}
return XmlConvert.ToBoolean(booleanValue);
}
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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CompiledELinqQueryState.cs
- ExpandedWrapper.cs
- OpenTypeLayoutCache.cs
- SecurityImpersonationBehavior.cs
- PeerName.cs
- ObjectQuery.cs
- NonSerializedAttribute.cs
- MemoryRecordBuffer.cs
- ComPlusServiceLoader.cs
- SQLCharsStorage.cs
- ObjectListCommandEventArgs.cs
- SqlColumnizer.cs
- SymbolPair.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- CachedFontFace.cs
- CoTaskMemSafeHandle.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- ApplyImportsAction.cs
- Classification.cs
- LinearGradientBrush.cs
- CollectionType.cs
- DataRowView.cs
- ViewStateModeByIdAttribute.cs
- IdentityHolder.cs
- DataGridColumn.cs
- ContainerUtilities.cs
- ObsoleteAttribute.cs
- ProvidersHelper.cs
- DPCustomTypeDescriptor.cs
- ResourceProviderFactory.cs
- VerticalAlignConverter.cs
- UnaryOperationBinder.cs
- XmlNamespaceDeclarationsAttribute.cs
- PageThemeCodeDomTreeGenerator.cs
- CryptographicAttribute.cs
- Substitution.cs
- ScriptRef.cs
- ImportedPolicyConversionContext.cs
- XmlSchemaAny.cs
- _SslState.cs
- FacetDescriptionElement.cs
- RepeatButtonAutomationPeer.cs
- NetTcpSecurity.cs
- FieldDescriptor.cs
- NonSerializedAttribute.cs
- QuaternionRotation3D.cs
- DependencyPropertyAttribute.cs
- Formatter.cs
- UnsignedPublishLicense.cs
- PagerSettings.cs
- JsonReader.cs
- IssuedTokenClientCredential.cs
- SqlConnectionStringBuilder.cs
- Application.cs
- DecoderExceptionFallback.cs
- PeoplePickerWrapper.cs
- ColumnBinding.cs
- Sequence.cs
- DataGridItemCollection.cs
- ToolZone.cs
- SafeTimerHandle.cs
- GeneralTransform3D.cs
- InternalResources.cs
- SafeEventLogReadHandle.cs
- ToolStripSeparatorRenderEventArgs.cs
- ComplusEndpointConfigContainer.cs
- BulletedListDesigner.cs
- MaskDescriptors.cs
- WSDualHttpSecurity.cs
- FrameworkElementAutomationPeer.cs
- FormViewDeletedEventArgs.cs
- MarkupCompilePass1.cs
- ExceptionUtil.cs
- CodeDOMProvider.cs
- DataGridViewLinkCell.cs
- SpecialFolderEnumConverter.cs
- XmlDataSourceView.cs
- HeaderElement.cs
- MenuTracker.cs
- MetadataCollection.cs
- FileDialog_Vista.cs
- DataGridCell.cs
- StringOutput.cs
- DataGridViewCellFormattingEventArgs.cs
- WebPartEditorOkVerb.cs
- XPathNodeInfoAtom.cs
- DecimalKeyFrameCollection.cs
- ProcessProtocolHandler.cs
- EnumType.cs
- basecomparevalidator.cs
- ScriptingSectionGroup.cs
- ComponentChangingEvent.cs
- SubpageParagraph.cs
- VectorAnimationBase.cs
- ApplicationServiceManager.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- EncryptedType.cs
- DetailsViewInsertedEventArgs.cs
- LicenseProviderAttribute.cs
- TiffBitmapDecoder.cs