Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / MS / Internal / Utility / SponsorHelper.cs / 1 / SponsorHelper.cs
using System; using System.Diagnostics; using System.Runtime.Remoting; using System.Runtime.Remoting.Lifetime; using System.Security; using System.Security.Permissions; namespace MS.Internal.Utility { #region SponsorHelper Class ////// We either mark the Sponsor as MarshalByRef or make it serializable. /// If we make it MarshalByRef, then this sponsor which is used to control /// the lifetime of a MBR object in turn needs to have another sponsor OR /// the sponsor can mark itself to remain alive for the life of the AppDomain /// by overriding InitializeLifetimeService and returning null OR the object /// can be marked as Serializeable instead of MBR in which case it is marshaled /// by value to the client appdomain and will not have the state of the host /// appdomain to make renewal decisions. In our case we don't have any state so /// its easier and better perf-wise to mark it Serializable. /// [Serializable] internal class SponsorHelper : ISponsor { #region Private Data private ILease _lease; private TimeSpan _timespan; #endregion Private Data #region Constructor internal SponsorHelper(ILease lease, TimeSpan timespan) { Debug.Assert(lease != null && timespan != null, "Lease and TimeSpan arguments cannot be null"); _lease = lease; _timespan = timespan; } #endregion Constructor #region ISponsor Interface TimeSpan ISponsor.Renewal(ILease lease) { if (lease == null) { throw new ArgumentNullException("lease"); } return _timespan; } #endregion ISponsor Interface #region Internal Methods ////// Critical - asserts permission for RemotingConfiguration /// TreatAsSafe - The constructor for this object is internal and this function does not take /// random parameters and hence can�t be used to keep random objects alive or access any other object /// in the application. /// [SecurityCritical, SecurityTreatAsSafe] [SecurityPermissionAttribute(SecurityAction.Assert, RemotingConfiguration = true)] internal void Register() { _lease.Register((ISponsor)this); } ////// Critical - asserts permission for RemotingConfiguration /// TreatAsSafe - The constructor for this object is internal and this function does not take /// random parameters and hence can�t be used to keep random objects alive or access any other object /// in the application. /// [SecurityCritical, SecurityTreatAsSafe] [SecurityPermissionAttribute(SecurityAction.Assert, RemotingConfiguration = true)] internal void Unregister() { _lease.Unregister((ISponsor)this); } #endregion Internal Methods } #endregion SponsorHelper Class } // 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
- oledbmetadatacollectionnames.cs
- BrowsableAttribute.cs
- pingexception.cs
- WebPartVerbCollection.cs
- TextTreeInsertUndoUnit.cs
- NativeMethods.cs
- MemberExpressionHelper.cs
- ClientProtocol.cs
- ListViewInsertionMark.cs
- RenderOptions.cs
- OdbcTransaction.cs
- ServiceX509SecurityTokenProvider.cs
- NoClickablePointException.cs
- DbParameterCollectionHelper.cs
- ErrorReporting.cs
- ContainerControl.cs
- Root.cs
- DataViewSettingCollection.cs
- WebDisplayNameAttribute.cs
- FontResourceCache.cs
- PropertyValue.cs
- RoleService.cs
- XamlStream.cs
- FileLoadException.cs
- EncoderFallback.cs
- FieldMetadata.cs
- HtmlTitle.cs
- SpellerHighlightLayer.cs
- FlowLayoutPanel.cs
- FlowDocumentReaderAutomationPeer.cs
- Adorner.cs
- MailDefinition.cs
- ConnectionManagementSection.cs
- LambdaCompiler.Address.cs
- WebPartConnectionCollection.cs
- PerformanceCounterPermission.cs
- ConfigUtil.cs
- CmsInterop.cs
- XmlSchemaSimpleTypeRestriction.cs
- DoWorkEventArgs.cs
- ByteStorage.cs
- FileLogRecordStream.cs
- GiveFeedbackEventArgs.cs
- QueryOutputWriter.cs
- StrongNamePublicKeyBlob.cs
- OutputCacheProviderCollection.cs
- PopOutPanel.cs
- SecurityContextTokenCache.cs
- ZoneMembershipCondition.cs
- TextViewDesigner.cs
- DataRow.cs
- Identity.cs
- XamlUtilities.cs
- RegexCompilationInfo.cs
- OracleDateTime.cs
- Dictionary.cs
- Facet.cs
- KeyboardDevice.cs
- CrossContextChannel.cs
- LogicalExpressionTypeConverter.cs
- MulticastIPAddressInformationCollection.cs
- DecimalAnimationBase.cs
- RIPEMD160Managed.cs
- HMACRIPEMD160.cs
- WebEventTraceProvider.cs
- iisPickupDirectory.cs
- MasterPageCodeDomTreeGenerator.cs
- HwndHostAutomationPeer.cs
- CellPartitioner.cs
- ToolStripMenuItemDesigner.cs
- QilVisitor.cs
- SelfSignedCertificate.cs
- UnionCqlBlock.cs
- TextStore.cs
- Timer.cs
- SynchronizingStream.cs
- XsdValidatingReader.cs
- WaitHandleCannotBeOpenedException.cs
- DataKeyCollection.cs
- ScrollChangedEventArgs.cs
- ObjectViewListener.cs
- XmlLoader.cs
- ToolStripDesignerAvailabilityAttribute.cs
- SqlServices.cs
- Rfc4050KeyFormatter.cs
- SizeChangedEventArgs.cs
- SerialErrors.cs
- PrtCap_Builder.cs
- SoapHeader.cs
- PageCodeDomTreeGenerator.cs
- DataSourceControl.cs
- GenericAuthenticationEventArgs.cs
- TraceContextRecord.cs
- OdbcConnectionPoolProviderInfo.cs
- BypassElement.cs
- ActivityMarkupSerializer.cs
- TransformerInfoCollection.cs
- RuntimeConfigurationRecord.cs
- _CommandStream.cs
- CrossSiteScriptingValidation.cs