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
- SelectionItemPatternIdentifiers.cs
- ListenerAdapter.cs
- ObjectDataSourceSelectingEventArgs.cs
- SqlMethods.cs
- Evidence.cs
- DataGridViewColumn.cs
- ThreadLocal.cs
- PageParser.cs
- StickyNoteContentControl.cs
- XPathParser.cs
- CircleHotSpot.cs
- SystemInformation.cs
- DataControlFieldCell.cs
- XsdCachingReader.cs
- Soap11ServerProtocol.cs
- PerformanceCounter.cs
- XmlHierarchicalDataSourceView.cs
- ReadWriteSpinLock.cs
- EntityUtil.cs
- CompoundFileIOPermission.cs
- Quad.cs
- PrefixQName.cs
- ControlType.cs
- ClearTypeHintValidation.cs
- UpdateProgress.cs
- RegexCapture.cs
- User.cs
- JobDuplex.cs
- BitmapEffectInputData.cs
- DesignerSerializationOptionsAttribute.cs
- MenuScrollingVisibilityConverter.cs
- DetailsViewUpdatedEventArgs.cs
- StrongName.cs
- srgsitem.cs
- HttpClientCertificate.cs
- XmlSchemaSimpleType.cs
- RegionIterator.cs
- MailMessageEventArgs.cs
- _ProxyRegBlob.cs
- configsystem.cs
- PropertyBuilder.cs
- ProfilePropertyMetadata.cs
- FileDialog_Vista.cs
- Hashtable.cs
- WebPartMenuStyle.cs
- BmpBitmapEncoder.cs
- FlowDocumentPageViewerAutomationPeer.cs
- CompilationRelaxations.cs
- DeclarativeCatalogPart.cs
- Header.cs
- ListBindingHelper.cs
- WmlCommandAdapter.cs
- GradientStop.cs
- WeakEventManager.cs
- XmlHierarchyData.cs
- TemplateFactory.cs
- StrokeNode.cs
- AlternateViewCollection.cs
- PrincipalPermission.cs
- RuleInfoComparer.cs
- CodeChecksumPragma.cs
- GenericWebPart.cs
- RoleServiceManager.cs
- ConditionalExpression.cs
- TypeValidationEventArgs.cs
- TextStore.cs
- ContextToken.cs
- FieldNameLookup.cs
- PageSettings.cs
- ClientTargetSection.cs
- filewebresponse.cs
- Item.cs
- BaseParser.cs
- TemplateComponentConnector.cs
- SmiXetterAccessMap.cs
- CodeAccessPermission.cs
- COM2PropertyDescriptor.cs
- X509ChainPolicy.cs
- FixedSOMSemanticBox.cs
- DropShadowBitmapEffect.cs
- PropertyValueChangedEvent.cs
- SimpleExpression.cs
- Popup.cs
- SourceFileBuildProvider.cs
- ObjectDataSourceEventArgs.cs
- PenThread.cs
- RangeBaseAutomationPeer.cs
- ProxyFragment.cs
- Decimal.cs
- DeclaredTypeValidatorAttribute.cs
- RelationshipSet.cs
- MobileControlPersister.cs
- GeneralTransformGroup.cs
- ObjectStateManagerMetadata.cs
- WebPartConnectionsConfigureVerb.cs
- TagMapInfo.cs
- IdentityReference.cs
- CorrelationTokenTypeConvertor.cs
- ProviderBase.cs
- TimeIntervalCollection.cs