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
- SystemNetworkInterface.cs
- ControlUtil.cs
- Menu.cs
- WebBrowserDesigner.cs
- WmlValidatorAdapter.cs
- DeploymentExceptionMapper.cs
- Grant.cs
- oledbmetadatacolumnnames.cs
- EntityDataSourceView.cs
- GeometryGroup.cs
- ReflectionServiceProvider.cs
- DataGridViewColumnEventArgs.cs
- ScrollChrome.cs
- SatelliteContractVersionAttribute.cs
- SqlGenericUtil.cs
- EncoderParameter.cs
- DrawingBrush.cs
- GeneralTransform3DCollection.cs
- HyperLinkColumn.cs
- ImageMapEventArgs.cs
- unsafenativemethodstextservices.cs
- ContentType.cs
- EntityReference.cs
- IndicShape.cs
- SimpleApplicationHost.cs
- ColorTransform.cs
- FolderBrowserDialog.cs
- ImageUrlEditor.cs
- SqlTypeConverter.cs
- DataGridViewAdvancedBorderStyle.cs
- SubpageParaClient.cs
- SettingsProperty.cs
- XmlTextReader.cs
- PropertyValueUIItem.cs
- Stroke.cs
- IMembershipProvider.cs
- VisualStateGroup.cs
- ScrollEvent.cs
- ICollection.cs
- GeometryModel3D.cs
- CalendarDesigner.cs
- ServerProtocol.cs
- ParameterCollectionEditor.cs
- SessionIDManager.cs
- VolatileResourceManager.cs
- XPathDescendantIterator.cs
- Transform3D.cs
- ClientTargetSection.cs
- DuplexClientBase.cs
- PolyLineSegment.cs
- BaseParser.cs
- StateMachineSubscription.cs
- configsystem.cs
- XsltArgumentList.cs
- ReaderWriterLock.cs
- CollectionTypeElement.cs
- DataMember.cs
- GridViewCancelEditEventArgs.cs
- WindowsMenu.cs
- CodeBlockBuilder.cs
- Camera.cs
- TextDecorationCollectionConverter.cs
- InkPresenterAutomationPeer.cs
- NamespaceTable.cs
- XmlTypeMapping.cs
- VariableQuery.cs
- CreateUserWizard.cs
- XAMLParseException.cs
- ResourceAssociationSetEnd.cs
- SafeTokenHandle.cs
- MenuItemCollection.cs
- Block.cs
- FixedSOMTable.cs
- XmlIncludeAttribute.cs
- ControlValuePropertyAttribute.cs
- wpf-etw.cs
- EntityDataSourceConfigureObjectContextPanel.cs
- ListBoxAutomationPeer.cs
- TypeSystemHelpers.cs
- InternalDuplexBindingElement.cs
- TextParagraphProperties.cs
- DependencyPropertyAttribute.cs
- DBAsyncResult.cs
- GroupLabel.cs
- Label.cs
- DataGridSortCommandEventArgs.cs
- PeerInputChannel.cs
- DataGridBeginningEditEventArgs.cs
- UnSafeCharBuffer.cs
- DataGridHeaderBorder.cs
- XmlAtomicValue.cs
- Journal.cs
- ToolStripControlHost.cs
- TableLayoutPanelResizeGlyph.cs
- CopyEncoder.cs
- SqlDataSourceSelectingEventArgs.cs
- OperatorExpressions.cs
- ArgumentReference.cs
- StoreConnection.cs
- MetadataUtil.cs