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
- IntegerValidatorAttribute.cs
- FormViewInsertedEventArgs.cs
- MinMaxParagraphWidth.cs
- SqlConnectionPoolGroupProviderInfo.cs
- DoubleConverter.cs
- CheckoutException.cs
- Int16Animation.cs
- CancellationToken.cs
- SoapIgnoreAttribute.cs
- StorageBasedPackageProperties.cs
- UpDownBase.cs
- IgnoreFileBuildProvider.cs
- XmlAttributeAttribute.cs
- LassoHelper.cs
- SpellerInterop.cs
- SqlMetaData.cs
- AttachedPropertyBrowsableAttribute.cs
- coordinatorscratchpad.cs
- ITreeGenerator.cs
- _LocalDataStore.cs
- ListView.cs
- StylusPointProperty.cs
- WindowsRebar.cs
- XmlObjectSerializerReadContext.cs
- PrePrepareMethodAttribute.cs
- XslException.cs
- AssertSection.cs
- PointAnimationClockResource.cs
- TemplatePropertyEntry.cs
- HtmlTableCell.cs
- Part.cs
- XsltArgumentList.cs
- RemoteWebConfigurationHostServer.cs
- Automation.cs
- DataViewManagerListItemTypeDescriptor.cs
- AttributeCollection.cs
- DataObjectAttribute.cs
- Point3DCollectionConverter.cs
- FrameworkContextData.cs
- HttpResponse.cs
- ConnectionInterfaceCollection.cs
- PathData.cs
- ProcessInfo.cs
- HtmlInputControl.cs
- DataGridViewAddColumnDialog.cs
- DataDocumentXPathNavigator.cs
- BoolExpressionVisitors.cs
- MouseCaptureWithinProperty.cs
- ProgressChangedEventArgs.cs
- OwnerDrawPropertyBag.cs
- SettingsPropertyValueCollection.cs
- StylusOverProperty.cs
- DataGridViewComboBoxColumnDesigner.cs
- ConsoleKeyInfo.cs
- FixedSOMElement.cs
- FactoryMaker.cs
- Brush.cs
- FontStyle.cs
- ReferenceConverter.cs
- DoubleLinkListEnumerator.cs
- processwaithandle.cs
- MenuItemBinding.cs
- Matrix3DStack.cs
- IOThreadScheduler.cs
- VSWCFServiceContractGenerator.cs
- TextProviderWrapper.cs
- PersonalizableTypeEntry.cs
- CompositeKey.cs
- MetadataItemCollectionFactory.cs
- ReferencedType.cs
- WindowsSpinner.cs
- PieceNameHelper.cs
- WindowsContainer.cs
- InspectionWorker.cs
- Peer.cs
- GeneralTransformCollection.cs
- MessageAction.cs
- DataErrorValidationRule.cs
- Socket.cs
- _Win32.cs
- HierarchicalDataBoundControlAdapter.cs
- SafeReadContext.cs
- EntitySetBaseCollection.cs
- InvokeGenerator.cs
- CategoryNameCollection.cs
- DrawingGroupDrawingContext.cs
- MissingSatelliteAssemblyException.cs
- IODescriptionAttribute.cs
- DataTableReader.cs
- AmbientLight.cs
- odbcmetadatafactory.cs
- SubMenuStyleCollection.cs
- VectorAnimationBase.cs
- HtmlInputImage.cs
- ReferencedCollectionType.cs
- WebMessageFormatHelper.cs
- SubMenuStyle.cs
- DoWorkEventArgs.cs
- RequestCacheManager.cs
- DefaultPropertyAttribute.cs