Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / SignatureResourcePool.cs / 1 / SignatureResourcePool.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.IdentityModel
{
using System.IO;
using System.Security.Cryptography;
using System.IdentityModel.Tokens;
using System.Xml;
using System.Text;
// for sequential use by one thread
sealed class SignatureResourcePool
{
const int BufferSize = 64;
CanonicalizationDriver canonicalizationDriver;
HashStream hashStream;
SHA1 sha1;
#if NO
XmlC14NWriter integratedWriter;
#endif
XmlDictionaryWriter utf8Writer;
byte[] encodingBuffer;
char[] base64Buffer;
public char[] TakeBase64Buffer()
{
if (this.base64Buffer == null)
{
this.base64Buffer = new char[BufferSize];
}
return this.base64Buffer;
}
public CanonicalizationDriver TakeCanonicalizationDriver()
{
if (this.canonicalizationDriver == null)
{
this.canonicalizationDriver = new CanonicalizationDriver();
}
else
{
this.canonicalizationDriver.Reset();
}
return this.canonicalizationDriver;
}
public byte[] TakeEncodingBuffer()
{
if (this.encodingBuffer == null)
{
this.encodingBuffer = new byte[BufferSize];
}
return this.encodingBuffer;
}
public HashAlgorithm TakeHashAlgorithm(string algorithm)
{
if (algorithm == SecurityAlgorithms.Sha1Digest)
{
return TakeSha1();
}
else
{
return CryptoHelper.CreateHashAlgorithm(algorithm);
}
}
public HashStream TakeHashStream(HashAlgorithm hash)
{
if (this.hashStream == null)
{
this.hashStream = new HashStream(hash);
}
else
{
this.hashStream.Reset(hash);
}
return this.hashStream;
}
public HashStream TakeHashStream(string algorithm)
{
return TakeHashStream(TakeHashAlgorithm(algorithm));
}
#if NO
public XmlC14NWriter TakeIntegratedWriter(Stream stream)
{
return TakeIntegratedWriter(stream, false, null);
}
public XmlC14NWriter TakeIntegratedWriter(Stream stream, bool includeComments, string[] inclusivePrefixes)
{
if (this.integratedWriter == null)
{
this.integratedWriter = new XmlC14NWriter(stream, includeComments, inclusivePrefixes);
}
else
{
this.integratedWriter.SetOutput(stream, includeComments, inclusivePrefixes);
}
return this.integratedWriter;
}
#endif
SHA1 TakeSha1()
{
if (this.sha1 == null)
{
this.sha1 = CryptoHelper.NewSha1HashAlgorithm();
}
else
{
this.sha1.Initialize();
}
return this.sha1;
}
public XmlDictionaryWriter TakeUtf8Writer()
{
if (this.utf8Writer == null)
{
this.utf8Writer = XmlDictionaryWriter.CreateTextWriter(Stream.Null, Encoding.UTF8, false);
}
else
{
((IXmlTextWriterInitializer) this.utf8Writer).SetOutput(Stream.Null, Encoding.UTF8, false);
}
return this.utf8Writer;
}
}
}
// 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
- ScrollBar.cs
- DesignerEditorPartChrome.cs
- CacheEntry.cs
- SqlProviderServices.cs
- DataStreams.cs
- PositiveTimeSpanValidatorAttribute.cs
- GeometryModel3D.cs
- ObsoleteAttribute.cs
- EntityDataSourceDataSelection.cs
- Normalization.cs
- ReadOnlyAttribute.cs
- JulianCalendar.cs
- KeyValuePairs.cs
- SafeNativeMethods.cs
- StrongNameUtility.cs
- WindowsSlider.cs
- DesignerActionVerbList.cs
- RotateTransform3D.cs
- BridgeDataRecord.cs
- PageThemeCodeDomTreeGenerator.cs
- ListCommandEventArgs.cs
- SqlDataSourceEnumerator.cs
- Viewport3DAutomationPeer.cs
- CanonicalFontFamilyReference.cs
- XsltLoader.cs
- PersonalizationProviderHelper.cs
- TextCompositionEventArgs.cs
- MasterPage.cs
- SmiXetterAccessMap.cs
- MsmqIntegrationElement.cs
- AudioBase.cs
- RelationshipEndMember.cs
- UIElementHelper.cs
- TableItemStyle.cs
- SchemaObjectWriter.cs
- ImageClickEventArgs.cs
- FormatSettings.cs
- XPathSelfQuery.cs
- UrlMappingsModule.cs
- ProfilePropertySettingsCollection.cs
- DeobfuscatingStream.cs
- SimpleTextLine.cs
- CodeTypeMember.cs
- ToolStripItemCollection.cs
- DataListCommandEventArgs.cs
- DataSetViewSchema.cs
- NativeMethods.cs
- Rules.cs
- DataListItemCollection.cs
- ActivationArguments.cs
- UiaCoreProviderApi.cs
- TargetControlTypeCache.cs
- NonSerializedAttribute.cs
- OutputWindow.cs
- WebPartConnectionsCloseVerb.cs
- AxDesigner.cs
- UriScheme.cs
- OLEDB_Util.cs
- TargetInvocationException.cs
- TextSelectionHelper.cs
- ToolStripDropTargetManager.cs
- XXXInfos.cs
- ResourceContainer.cs
- CreateUserWizard.cs
- EntityDesignPluralizationHandler.cs
- EventLogPermissionAttribute.cs
- StorageMappingItemCollection.cs
- ProfilePropertySettings.cs
- DataGridCommandEventArgs.cs
- LabelLiteral.cs
- NumberFormatter.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- RayHitTestParameters.cs
- SystemDiagnosticsSection.cs
- VariableElement.cs
- WorkflowApplicationCompletedEventArgs.cs
- NavigationPropertySingletonExpression.cs
- BindStream.cs
- SafeNativeMethods.cs
- ColorConverter.cs
- WpfXamlMember.cs
- WebResourceAttribute.cs
- SessionStateUtil.cs
- AppDomain.cs
- ApplicationException.cs
- WebConfigurationHostFileChange.cs
- WebPartTransformerCollection.cs
- NavigationWindowAutomationPeer.cs
- DataSourceViewSchemaConverter.cs
- SerializationHelper.cs
- RecordConverter.cs
- unsafenativemethodstextservices.cs
- Interlocked.cs
- HTMLTextWriter.cs
- TableItemProviderWrapper.cs
- Font.cs
- ProcessInfo.cs
- Control.cs
- SpnEndpointIdentity.cs
- NumericExpr.cs