Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / XmlHelper.cs / 1305376 / XmlHelper.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel
{
using System.IO;
using System.Text;
using System.Xml;
static class XmlHelper
{
internal static string GetWhiteSpace(XmlReader reader)
{
string s = null;
StringBuilder sb = null;
while (reader.NodeType == XmlNodeType.Whitespace || reader.NodeType == XmlNodeType.SignificantWhitespace)
{
if (sb != null)
{
sb.Append(reader.Value);
}
else if (s != null)
{
sb = new StringBuilder(s);
sb.Append(reader.Value);
s = null;
}
else
{
s = reader.Value;
}
if (!reader.Read())
{
break;
}
}
return sb != null ? sb.ToString() : s;
}
internal static void OnRequiredAttributeMissing(string attrName, string elementName)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.RequiredAttributeMissing, attrName, elementName)));
}
internal static string ReadEmptyElementAndRequiredAttribute(XmlDictionaryReader reader,
XmlDictionaryString name, XmlDictionaryString namespaceUri, XmlDictionaryString attributeName,
out string prefix)
{
reader.MoveToStartElement(name, namespaceUri);
prefix = reader.Prefix;
bool isEmptyElement = reader.IsEmptyElement;
string value = reader.GetAttribute(attributeName, null);
if (value == null)
{
OnRequiredAttributeMissing(attributeName.Value, null);
}
reader.Read();
if (!isEmptyElement)
{
reader.ReadEndElement();
}
return value;
}
internal static string ReadTextElementAsTrimmedString(XmlElement element)
{
if (element == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
XmlReader reader = new XmlNodeReader(element);
reader.MoveToContent();
return XmlUtil.Trim(reader.ReadElementContentAsString());
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel
{
using System.IO;
using System.Text;
using System.Xml;
static class XmlHelper
{
internal static string GetWhiteSpace(XmlReader reader)
{
string s = null;
StringBuilder sb = null;
while (reader.NodeType == XmlNodeType.Whitespace || reader.NodeType == XmlNodeType.SignificantWhitespace)
{
if (sb != null)
{
sb.Append(reader.Value);
}
else if (s != null)
{
sb = new StringBuilder(s);
sb.Append(reader.Value);
s = null;
}
else
{
s = reader.Value;
}
if (!reader.Read())
{
break;
}
}
return sb != null ? sb.ToString() : s;
}
internal static void OnRequiredAttributeMissing(string attrName, string elementName)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.RequiredAttributeMissing, attrName, elementName)));
}
internal static string ReadEmptyElementAndRequiredAttribute(XmlDictionaryReader reader,
XmlDictionaryString name, XmlDictionaryString namespaceUri, XmlDictionaryString attributeName,
out string prefix)
{
reader.MoveToStartElement(name, namespaceUri);
prefix = reader.Prefix;
bool isEmptyElement = reader.IsEmptyElement;
string value = reader.GetAttribute(attributeName, null);
if (value == null)
{
OnRequiredAttributeMissing(attributeName.Value, null);
}
reader.Read();
if (!isEmptyElement)
{
reader.ReadEndElement();
}
return value;
}
internal static string ReadTextElementAsTrimmedString(XmlElement element)
{
if (element == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
}
XmlReader reader = new XmlNodeReader(element);
reader.MoveToContent();
return XmlUtil.Trim(reader.ReadElementContentAsString());
}
}
}
// 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
- PageVisual.cs
- SoapCommonClasses.cs
- ExpressionWriter.cs
- SmiEventSink_Default.cs
- CodeArgumentReferenceExpression.cs
- DataError.cs
- SecurityValidationBehavior.cs
- SafeFindHandle.cs
- TypeDelegator.cs
- DotExpr.cs
- ExpressionPrinter.cs
- MSAAWinEventWrap.cs
- ISFClipboardData.cs
- WebPartChrome.cs
- HotCommands.cs
- IPPacketInformation.cs
- WindowsAuthenticationModule.cs
- IgnoreDataMemberAttribute.cs
- FontEmbeddingManager.cs
- TempFiles.cs
- AttachmentCollection.cs
- SHA384.cs
- CommentAction.cs
- ColumnHeaderConverter.cs
- StringPropertyBuilder.cs
- RepeatEnumerable.cs
- TaskFileService.cs
- DependencyPropertyKey.cs
- EventWaitHandleSecurity.cs
- DataViewManager.cs
- ProfileManager.cs
- BoundingRectTracker.cs
- XmlAnyElementAttributes.cs
- SubMenuStyleCollection.cs
- ToggleButton.cs
- IncrementalReadDecoders.cs
- XmlSchemaAnyAttribute.cs
- PerformanceCounterPermission.cs
- ShapeTypeface.cs
- CookielessHelper.cs
- TypeConverterValueSerializer.cs
- ArraySortHelper.cs
- Certificate.cs
- Partitioner.cs
- WindowVisualStateTracker.cs
- TypeResolver.cs
- PriorityChain.cs
- ReadOnlyMetadataCollection.cs
- XmlSerializableReader.cs
- Preprocessor.cs
- BevelBitmapEffect.cs
- HttpProfileGroupBase.cs
- TypeTypeConverter.cs
- Literal.cs
- _RequestCacheProtocol.cs
- NgenServicingAttributes.cs
- ProxyElement.cs
- Win32.cs
- GeneralTransform2DTo3D.cs
- PassportAuthenticationEventArgs.cs
- CurrencyWrapper.cs
- FormsAuthenticationUserCollection.cs
- WebPartConnectionsDisconnectVerb.cs
- XPathItem.cs
- BevelBitmapEffect.cs
- RectangleConverter.cs
- ExpandableObjectConverter.cs
- Scheduler.cs
- WebAdminConfigurationHelper.cs
- CommonDialog.cs
- HtmlContainerControl.cs
- NotSupportedException.cs
- BuildManagerHost.cs
- FaultException.cs
- OAVariantLib.cs
- UpdateCommandGenerator.cs
- FileDialog.cs
- AudioFileOut.cs
- FixedPageStructure.cs
- DataGridViewAccessibleObject.cs
- PostBackOptions.cs
- UriPrefixTable.cs
- TCEAdapterGenerator.cs
- TableRowCollection.cs
- BitArray.cs
- DetailsViewDesigner.cs
- FontSourceCollection.cs
- EditorPartChrome.cs
- HtmlAnchor.cs
- HtmlElementEventArgs.cs
- InputProviderSite.cs
- TextEditorTables.cs
- WCFBuildProvider.cs
- InvalidWMPVersionException.cs
- ModifiableIteratorCollection.cs
- WebPartManagerDesigner.cs
- SendKeys.cs
- Geometry3D.cs
- RemotingServices.cs
- ComponentSerializationService.cs