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
- DesignerView.xaml.cs
- TaiwanCalendar.cs
- TickBar.cs
- DesignSurfaceCollection.cs
- IHttpResponseInternal.cs
- X509IssuerSerialKeyIdentifierClause.cs
- Annotation.cs
- SimplePropertyEntry.cs
- WorkflowMarkupSerializationProvider.cs
- ModelFactory.cs
- ChooseAction.cs
- TextServicesDisplayAttribute.cs
- BoolExpressionVisitors.cs
- DockAndAnchorLayout.cs
- TypeTypeConverter.cs
- figurelengthconverter.cs
- PatternMatcher.cs
- VectorValueSerializer.cs
- OleDbCommandBuilder.cs
- ConnectionsZone.cs
- ArraySubsetEnumerator.cs
- Popup.cs
- RequestSecurityTokenForGetBrowserToken.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- MailAddress.cs
- CuspData.cs
- DesignTimeVisibleAttribute.cs
- NetMsmqSecurityMode.cs
- ControlBuilder.cs
- ClientConfigPaths.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- PropertyMapper.cs
- IIS7UserPrincipal.cs
- HyperLinkDataBindingHandler.cs
- UdpAnnouncementEndpoint.cs
- DataBoundLiteralControl.cs
- SafeNativeMethods.cs
- TimelineClockCollection.cs
- DesignTableCollection.cs
- DynamicFilter.cs
- ImmutableCollection.cs
- RectKeyFrameCollection.cs
- DataFieldEditor.cs
- MatrixTransform.cs
- ReaderWriterLockWrapper.cs
- PropertyTabChangedEvent.cs
- DataRelationPropertyDescriptor.cs
- HttpException.cs
- _CacheStreams.cs
- GroupByExpressionRewriter.cs
- GPRECT.cs
- ToolStripGripRenderEventArgs.cs
- CodeBlockBuilder.cs
- TabletCollection.cs
- XmlSchemaComplexType.cs
- ResourceWriter.cs
- WindowCollection.cs
- Permission.cs
- NameValueFileSectionHandler.cs
- SimplePropertyEntry.cs
- ValidationPropertyAttribute.cs
- UrlPath.cs
- ConnectionManager.cs
- ExpressionNormalizer.cs
- Win32.cs
- RawTextInputReport.cs
- TargetPerspective.cs
- DocumentSequenceHighlightLayer.cs
- Object.cs
- NonVisualControlAttribute.cs
- ResourceDefaultValueAttribute.cs
- StringWriter.cs
- PropertyGridEditorPart.cs
- Timer.cs
- TransformDescriptor.cs
- NullableFloatMinMaxAggregationOperator.cs
- DBSchemaRow.cs
- SqlProfileProvider.cs
- ClientSettingsSection.cs
- CopyAttributesAction.cs
- EntitySqlQueryCacheEntry.cs
- OdbcCommandBuilder.cs
- CDSCollectionETWBCLProvider.cs
- ListViewGroupItemCollection.cs
- RequestSecurityToken.cs
- EntityDataSourceValidationException.cs
- RestrictedTransactionalPackage.cs
- DbDeleteCommandTree.cs
- MatrixConverter.cs
- AnnotationHelper.cs
- DataGridLength.cs
- Brush.cs
- DictionaryEntry.cs
- CleanUpVirtualizedItemEventArgs.cs
- SrgsRule.cs
- BinaryMethodMessage.cs
- COM2IProvidePropertyBuilderHandler.cs
- WindowsButton.cs
- TimeStampChecker.cs
- Form.cs