Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / NegotiationTokenAuthenticatorStateCache.cs / 1 / NegotiationTokenAuthenticatorStateCache.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Security
{
using System;
using System.ServiceModel;
using System.Collections;
using System.Runtime.InteropServices;
using System.Threading;
using System.Diagnostics;
sealed class NegotiationTokenAuthenticatorStateCache : TimeBoundedCache
where T : NegotiationTokenAuthenticatorState
{
static int lowWaterMark = 50;
static TimeSpan purgingInterval = TimeSpan.FromMinutes(10);
TimeSpan cachingSpan;
public NegotiationTokenAuthenticatorStateCache(TimeSpan cachingSpan, int maximumCachedState)
: base(lowWaterMark, maximumCachedState, null, PurgingMode.TimerBasedPurge, TimeSpan.FromTicks(cachingSpan.Ticks >> 2), true)
{
this.cachingSpan = cachingSpan;
}
public void AddState(string context, T state)
{
DateTime expirationTime = TimeoutHelper.Add(DateTime.UtcNow, this.cachingSpan);
bool wasStateAdded = base.TryAddItem(context, state, expirationTime, false);
if (!wasStateAdded)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperWarning(new SecurityNegotiationException(SR.GetString(SR.NegotiationStateAlreadyPresent, context)));
}
}
public T GetState(string context)
{
return (this.GetItem(context) as T);
}
public void RemoveState(string context)
{
this.TryRemoveItem(context);
}
protected override ArrayList OnQuotaReached(Hashtable cacheTable)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QuotaExceededException(SR.GetString(SR.CachedNegotiationStateQuotaReached, this.Capacity)));
}
protected override void OnRemove(object item)
{
((IDisposable)item).Dispose();
base.OnRemove(item);
}
}
}
// 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
- ExpressionBuilderCollection.cs
- tibetanshape.cs
- Menu.cs
- BrowserCapabilitiesCompiler.cs
- SecUtil.cs
- AnonymousIdentificationModule.cs
- Claim.cs
- ServiceThrottle.cs
- Rotation3D.cs
- SiteMapHierarchicalDataSourceView.cs
- EntityException.cs
- WindowsBrush.cs
- PersonalizationProviderCollection.cs
- DefaultMemberAttribute.cs
- PageCodeDomTreeGenerator.cs
- TypeUnloadedException.cs
- XmlReflectionImporter.cs
- DbConnectionClosed.cs
- AssemblyAttributes.cs
- InputBuffer.cs
- HttpWebRequest.cs
- MimeMapping.cs
- COM2FontConverter.cs
- ResourceManager.cs
- UserPreferenceChangingEventArgs.cs
- EntityDataSourceWrapperCollection.cs
- CompilerTypeWithParams.cs
- MailAddress.cs
- LogSwitch.cs
- JournalNavigationScope.cs
- PermissionListSet.cs
- HuffmanTree.cs
- TextRange.cs
- TypeConverter.cs
- HeaderCollection.cs
- CallbackHandler.cs
- Button.cs
- RegisteredScript.cs
- RequestTimeoutManager.cs
- MessageContractExporter.cs
- ButtonAutomationPeer.cs
- AbsoluteQuery.cs
- SqlConnectionPoolProviderInfo.cs
- ContextInformation.cs
- XamlGridLengthSerializer.cs
- DataSourceView.cs
- RuleSettingsCollection.cs
- SiteIdentityPermission.cs
- __Filters.cs
- DataGridViewAccessibleObject.cs
- InternalUserCancelledException.cs
- DateTimeSerializationSection.cs
- MetricEntry.cs
- ObjectDataSource.cs
- ItemDragEvent.cs
- ConnectionManagementSection.cs
- XPathDocumentIterator.cs
- SByteConverter.cs
- XmlILTrace.cs
- SessionStateSection.cs
- BeginSelectCardRequest.cs
- ResourceDefaultValueAttribute.cs
- DesignerActionUI.cs
- PolyBezierSegment.cs
- ResourceReferenceExpression.cs
- VisualBrush.cs
- AnnotationAdorner.cs
- PeerInvitationResponse.cs
- RadioButtonRenderer.cs
- OLEDB_Util.cs
- Timer.cs
- EntityClassGenerator.cs
- EqualityComparer.cs
- TextViewBase.cs
- Win32SafeHandles.cs
- XPathParser.cs
- OptimalBreakSession.cs
- UriPrefixTable.cs
- AssemblyBuilder.cs
- QuestionEventArgs.cs
- WindowPatternIdentifiers.cs
- RuleConditionDialog.cs
- DefaultParameterValueAttribute.cs
- UpdateTracker.cs
- ReferencedType.cs
- ToolStripRendererSwitcher.cs
- NullableBoolConverter.cs
- TextEffect.cs
- XmlElementAttribute.cs
- DataControlFieldCell.cs
- GeneralTransform3D.cs
- BinaryUtilClasses.cs
- SmtpDigestAuthenticationModule.cs
- SafeRightsManagementSessionHandle.cs
- UriPrefixTable.cs
- CheckBoxRenderer.cs
- FixedTextPointer.cs
- ToolStripActionList.cs
- CapabilitiesSection.cs
- SqlCrossApplyToCrossJoin.cs