Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / XmlAttributeHolder.cs / 1 / XmlAttributeHolder.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel
{
using System.Xml;
struct XmlAttributeHolder
{
string prefix;
string ns;
string localName;
string value;
public static XmlAttributeHolder[] emptyArray = new XmlAttributeHolder[0];
public XmlAttributeHolder(string prefix, string localName, string ns, string value)
{
this.prefix = prefix;
this.localName = localName;
this.ns = ns;
this.value = value;
}
public string Prefix
{
get { return prefix; }
}
public string NamespaceUri
{
get { return ns; }
}
public string LocalName
{
get { return localName; }
}
public string Value
{
get { return value; }
}
public void WriteTo(XmlWriter writer)
{
writer.WriteStartAttribute(prefix, localName, ns);
writer.WriteString(value);
writer.WriteEndAttribute();
}
public static void WriteAttributes(XmlAttributeHolder[] attributes, XmlWriter writer)
{
for (int i = 0; i < attributes.Length; i++)
attributes[i].WriteTo(writer);
}
public static XmlAttributeHolder[] ReadAttributes(XmlDictionaryReader reader)
{
int maxSizeOfHeaders = int.MaxValue;
return ReadAttributes(reader, ref maxSizeOfHeaders);
}
public static XmlAttributeHolder[] ReadAttributes(XmlDictionaryReader reader, ref int maxSizeOfHeaders)
{
if (reader.AttributeCount == 0)
return emptyArray;
XmlAttributeHolder[] attributes = new XmlAttributeHolder[reader.AttributeCount];
reader.MoveToFirstAttribute();
for (int i = 0; i < attributes.Length; i++)
{
string ns = reader.NamespaceURI;
string localName = reader.LocalName;
string prefix = reader.Prefix;
string value = string.Empty;
while (reader.ReadAttributeValue())
{
if (value.Length == 0)
value = reader.Value;
else
value += reader.Value;
}
Deduct(prefix, ref maxSizeOfHeaders);
Deduct(localName, ref maxSizeOfHeaders);
Deduct(ns, ref maxSizeOfHeaders);
Deduct(value, ref maxSizeOfHeaders);
attributes[i] = new XmlAttributeHolder(prefix, localName, ns, value);
reader.MoveToNextAttribute();
}
reader.MoveToElement();
return attributes;
}
static void Deduct(string s, ref int maxSizeOfHeaders)
{
int byteCount = s.Length * sizeof(char);
if (byteCount > maxSizeOfHeaders)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.XmlBufferQuotaExceeded)));
}
maxSizeOfHeaders -= byteCount;
}
public static string GetAttribute(XmlAttributeHolder[] attributes, string localName, string ns)
{
for (int i = 0; i < attributes.Length; i++)
if (attributes[i].LocalName == localName && attributes[i].NamespaceUri == ns)
return attributes[i].Value;
return null;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SemanticAnalyzer.cs
- ToolStripSettings.cs
- ImportContext.cs
- ProviderCollection.cs
- DataGrid.cs
- SrgsDocument.cs
- Math.cs
- RunClient.cs
- ContractReference.cs
- WebPartDescription.cs
- GenericTransactionFlowAttribute.cs
- HttpProtocolReflector.cs
- PermissionToken.cs
- WinCategoryAttribute.cs
- WhitespaceRuleReader.cs
- Cursors.cs
- DataRowExtensions.cs
- DesignerTextBoxAdapter.cs
- XmlTextReaderImpl.cs
- ImageButton.cs
- LoginUtil.cs
- Error.cs
- OletxVolatileEnlistment.cs
- RouteUrlExpressionBuilder.cs
- XmlDataDocument.cs
- SiteMapProvider.cs
- ObjectCacheHost.cs
- ScanQueryOperator.cs
- XmlExpressionDumper.cs
- XmlSchemas.cs
- mediaeventargs.cs
- OpCodes.cs
- TogglePattern.cs
- InstanceCreationEditor.cs
- AsymmetricSignatureDeformatter.cs
- FixedFlowMap.cs
- BuildProviderUtils.cs
- cache.cs
- GridLengthConverter.cs
- ProjectionCamera.cs
- LogFlushAsyncResult.cs
- Rotation3D.cs
- SourceCollection.cs
- ContentValidator.cs
- ClientFormsAuthenticationCredentials.cs
- CapiNative.cs
- RuleEngine.cs
- DesignerForm.cs
- HScrollBar.cs
- RegistryKey.cs
- ImageIndexConverter.cs
- FixedLineResult.cs
- LoadWorkflowCommand.cs
- PreProcessor.cs
- CurrentTimeZone.cs
- ClientFormsIdentity.cs
- _ListenerRequestStream.cs
- ParsedAttributeCollection.cs
- _SSPISessionCache.cs
- ProviderSettingsCollection.cs
- SoapExtensionTypeElementCollection.cs
- SharedDp.cs
- ThemeDirectoryCompiler.cs
- Avt.cs
- HttpContext.cs
- AlgoModule.cs
- RelationshipEntry.cs
- Compilation.cs
- JobInputBins.cs
- XPathPatternParser.cs
- StrongNameSignatureInformation.cs
- StyleCollection.cs
- ConfigurationStrings.cs
- DNS.cs
- _HeaderInfo.cs
- Propagator.Evaluator.cs
- HtmlListAdapter.cs
- PerfCounters.cs
- AccessibilityHelperForXpWin2k3.cs
- RootProfilePropertySettingsCollection.cs
- CodeChecksumPragma.cs
- AssemblyBuilderData.cs
- ConstNode.cs
- ThreadAbortException.cs
- _SecureChannel.cs
- NamespaceInfo.cs
- GuidelineCollection.cs
- AccessedThroughPropertyAttribute.cs
- PermissionSetEnumerator.cs
- SafeNativeMethodsCLR.cs
- CodeDomConfigurationHandler.cs
- RichTextBoxConstants.cs
- Int32AnimationUsingKeyFrames.cs
- SimpleLine.cs
- objectquery_tresulttype.cs
- GroupBox.cs
- EditorZoneBase.cs
- DataGridColumn.cs
- HtmlForm.cs
- BindingExpressionBase.cs