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
- FormsAuthenticationUserCollection.cs
- OdbcInfoMessageEvent.cs
- GeometryCombineModeValidation.cs
- DataFormat.cs
- TypeConverterHelper.cs
- ProxyManager.cs
- DBCommand.cs
- SmtpFailedRecipientException.cs
- PublishLicense.cs
- KeyToListMap.cs
- TrimSurroundingWhitespaceAttribute.cs
- ToolStripContentPanel.cs
- Thumb.cs
- bindurihelper.cs
- EntityDataSourceChangingEventArgs.cs
- _NegoStream.cs
- XmlLanguageConverter.cs
- Vector3DAnimationBase.cs
- NavigationProperty.cs
- ClientEventManager.cs
- ConstructorNeedsTagAttribute.cs
- DataGridViewAutoSizeModeEventArgs.cs
- MethodExpression.cs
- UserControlBuildProvider.cs
- EmulateRecognizeCompletedEventArgs.cs
- PlanCompiler.cs
- VirtualDirectoryMapping.cs
- ConfigXmlText.cs
- ExtensionQuery.cs
- AnnotationComponentManager.cs
- BinaryWriter.cs
- AnnotationResource.cs
- MediaTimeline.cs
- DataListItemCollection.cs
- _AuthenticationState.cs
- InkSerializer.cs
- OrderedDictionaryStateHelper.cs
- HMACSHA512.cs
- BCLDebug.cs
- XsdBuilder.cs
- SqlDataSourceEnumerator.cs
- PropertyStore.cs
- FunctionQuery.cs
- ControlType.cs
- PropertyBuilder.cs
- ParameterCollection.cs
- MarkupWriter.cs
- TemplateBindingExtensionConverter.cs
- TraceLevelHelper.cs
- SqlDependency.cs
- CompiledXpathExpr.cs
- TextParagraphProperties.cs
- Clause.cs
- FloatUtil.cs
- CommandHelpers.cs
- TextPattern.cs
- HandlerBase.cs
- Emitter.cs
- Duration.cs
- DbBuffer.cs
- IndexOutOfRangeException.cs
- SizeF.cs
- SmiConnection.cs
- Vector3DAnimation.cs
- DmlSqlGenerator.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- HeaderedContentControl.cs
- BamlResourceSerializer.cs
- _SSPISessionCache.cs
- MissingManifestResourceException.cs
- Activity.cs
- TriState.cs
- MonthCalendar.cs
- DefaultValueConverter.cs
- FilterEventArgs.cs
- RSAOAEPKeyExchangeFormatter.cs
- EditorZone.cs
- ReceiveMessageRecord.cs
- OwnerDrawPropertyBag.cs
- metadatamappinghashervisitor.cs
- StylusPointPropertyId.cs
- XmlWellformedWriter.cs
- MarkedHighlightComponent.cs
- FixedSOMGroup.cs
- ReferentialConstraint.cs
- XmlPropertyBag.cs
- XmlHelper.cs
- MDIClient.cs
- XPathBinder.cs
- NameValuePermission.cs
- ReverseComparer.cs
- ChtmlCalendarAdapter.cs
- ApplicationManager.cs
- MeasureData.cs
- JsonStringDataContract.cs
- PeerObject.cs
- SamlSecurityToken.cs
- SourceSwitch.cs
- RuleAction.cs
- Span.cs