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
- GACIdentityPermission.cs
- ToolCreatedEventArgs.cs
- ManagedIStream.cs
- ListControl.cs
- BitStack.cs
- MetadataItemEmitter.cs
- ToolStripPanelSelectionGlyph.cs
- DayRenderEvent.cs
- ParameterInfo.cs
- HtmlInputButton.cs
- ManagementEventArgs.cs
- Command.cs
- WebConfigurationHostFileChange.cs
- PointAnimationUsingPath.cs
- OdbcEnvironmentHandle.cs
- ControlHelper.cs
- EdmTypeAttribute.cs
- AssertSection.cs
- __Error.cs
- CharAnimationUsingKeyFrames.cs
- ThaiBuddhistCalendar.cs
- PieceNameHelper.cs
- BaseTemplateParser.cs
- BitSet.cs
- KnownBoxes.cs
- WindowsFormsSynchronizationContext.cs
- InputMethodStateChangeEventArgs.cs
- FixedDSBuilder.cs
- SevenBitStream.cs
- NetworkInformationException.cs
- ConfigXmlSignificantWhitespace.cs
- EntityDataSourceSelectedEventArgs.cs
- WindowInteropHelper.cs
- DbConnectionPoolIdentity.cs
- AppendHelper.cs
- MimeXmlImporter.cs
- xdrvalidator.cs
- TraceUtils.cs
- ParagraphResult.cs
- StateInitializationDesigner.cs
- GridLengthConverter.cs
- DataListItem.cs
- MessageQueueInstaller.cs
- FastEncoder.cs
- Wildcard.cs
- Visual.cs
- XmlReflectionMember.cs
- OdbcConnectionString.cs
- HostProtectionException.cs
- OracleTimeSpan.cs
- ExternalFile.cs
- DialogResultConverter.cs
- NotCondition.cs
- updatecommandorderer.cs
- PanelStyle.cs
- HtmlWindow.cs
- DataServiceConfiguration.cs
- KeyedPriorityQueue.cs
- OperationCanceledException.cs
- TableRowGroup.cs
- WindowsTooltip.cs
- ConsoleEntryPoint.cs
- PrePostDescendentsWalker.cs
- ChangeConflicts.cs
- DetailsViewRow.cs
- SHA1Managed.cs
- ResourcesChangeInfo.cs
- ConnectionStringsSection.cs
- UpdateManifestForBrowserApplication.cs
- ObjectList.cs
- ToolStripScrollButton.cs
- WindowsFormsSectionHandler.cs
- TemplateAction.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- HtmlShimManager.cs
- RegexParser.cs
- ByteAnimationUsingKeyFrames.cs
- RIPEMD160.cs
- XmlSchemaElement.cs
- TextTreeUndoUnit.cs
- MultiPageTextView.cs
- SoapMessage.cs
- XmlSchemaGroup.cs
- InvalidPropValue.cs
- RbTree.cs
- Thickness.cs
- IncomingWebRequestContext.cs
- DataTransferEventArgs.cs
- Transform.cs
- SQLInt64.cs
- NameHandler.cs
- TemplateApplicationHelper.cs
- AppSettingsExpressionBuilder.cs
- ObjectPersistData.cs
- RegexGroupCollection.cs
- IfJoinedCondition.cs
- ComplexObject.cs
- PathSegmentCollection.cs
- StreamResourceInfo.cs
- ByeMessageCD1.cs