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
- ArrangedElementCollection.cs
- ParameterModifier.cs
- Stack.cs
- AuthenticationSection.cs
- SuppressMergeCheckAttribute.cs
- WorkflowNamespace.cs
- MenuAdapter.cs
- SamlSecurityTokenAuthenticator.cs
- XmlSchemaValidationException.cs
- ChoiceConverter.cs
- IConvertible.cs
- TimeIntervalCollection.cs
- HitTestDrawingContextWalker.cs
- MatrixTransform.cs
- SecurityTokenValidationException.cs
- TextViewElement.cs
- VirtualizingPanel.cs
- BackStopAuthenticationModule.cs
- DispatcherObject.cs
- SafeProcessHandle.cs
- RepeaterDataBoundAdapter.cs
- TextWriterTraceListener.cs
- DelegatedStream.cs
- StrokeCollection2.cs
- TableLayoutPanel.cs
- MimeReturn.cs
- Renderer.cs
- ListView.cs
- XmlWriterTraceListener.cs
- UnmanagedMemoryStreamWrapper.cs
- SamlEvidence.cs
- ReadOnlyPropertyMetadata.cs
- ParseChildrenAsPropertiesAttribute.cs
- EncoderParameter.cs
- NamespaceList.cs
- DesignerActionKeyboardBehavior.cs
- RegexTree.cs
- OracleBoolean.cs
- SqlUtil.cs
- DataGridItemAutomationPeer.cs
- base64Transforms.cs
- ClientTargetSection.cs
- StandardCommands.cs
- AssemblyBuilder.cs
- BinaryParser.cs
- ElapsedEventArgs.cs
- QueryInterceptorAttribute.cs
- BitmapEffectDrawing.cs
- KeyToListMap.cs
- Assert.cs
- ListBase.cs
- TcpTransportElement.cs
- ListControl.cs
- CryptoApi.cs
- SqlUserDefinedTypeAttribute.cs
- WS2007HttpBindingElement.cs
- ProcessRequestArgs.cs
- LocalTransaction.cs
- ExpandoObject.cs
- ZoneMembershipCondition.cs
- Baml2006ReaderContext.cs
- PrtCap_Public_Simple.cs
- SQLDateTime.cs
- RtType.cs
- ResourceProperty.cs
- HttpPostedFileBase.cs
- WmpBitmapEncoder.cs
- SocketException.cs
- CustomGrammar.cs
- ToolStripDropDownItem.cs
- SelectionPattern.cs
- FamilyMapCollection.cs
- XamlBuildTaskServices.cs
- OleDbDataAdapter.cs
- UInt32.cs
- SchemaLookupTable.cs
- prompt.cs
- PlanCompilerUtil.cs
- Symbol.cs
- BindingContext.cs
- RenderDataDrawingContext.cs
- DataGridRowEventArgs.cs
- XamlTreeBuilder.cs
- SelectionItemProviderWrapper.cs
- SupportingTokenAuthenticatorSpecification.cs
- WindowsStatic.cs
- DbParameterHelper.cs
- ItemCheckedEvent.cs
- HttpCapabilitiesSectionHandler.cs
- OleDbEnumerator.cs
- OnOperation.cs
- RtfToXamlReader.cs
- QueryStringParameter.cs
- FilteredDataSetHelper.cs
- NodeFunctions.cs
- CheckedPointers.cs
- BitmapEffectCollection.cs
- SingleResultAttribute.cs
- SectionInformation.cs
- ProcessThread.cs