ISponsor 介面
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指示實作器想要成為存留期使用期 (Lifetime Lease) 贊助者。
public interface class ISponsor
public interface ISponsor
[System.Runtime.InteropServices.ComVisible(true)]
public interface ISponsor
type ISponsor = interface
[<System.Runtime.InteropServices.ComVisible(true)>]
type ISponsor = interface
Public Interface ISponsor
- 衍生
- 屬性
範例
public ref class MyClientSponsor: public MarshalByRefObject, public ISponsor
{
private:
DateTime lastRenewal;
public:
MyClientSponsor()
{
lastRenewal = DateTime::Now;
}
[SecurityPermissionAttribute(SecurityAction::LinkDemand,Flags=SecurityPermissionFlag::Infrastructure)]
virtual TimeSpan Renewal( ILease^ /* lease */ )
{
Console::WriteLine( "Request to renew the lease time." );
Console::WriteLine( "Time since last renewal: {0}",
DateTime::Now - lastRenewal );
lastRenewal = DateTime::Now;
return TimeSpan::FromSeconds( 20 );
}
};
public class MyClientSponsor : MarshalByRefObject, ISponsor
{
private DateTime lastRenewal;
public MyClientSponsor()
{
lastRenewal = DateTime.Now;
}
public TimeSpan Renewal(ILease lease)
{
Console.WriteLine("Request to renew the lease time.");
Console.WriteLine("Time since last renewal: " +
(DateTime.Now - lastRenewal).ToString());
lastRenewal = DateTime.Now;
return TimeSpan.FromSeconds(20);
}
}
Public Class MyClientSponsor
Inherits MarshalByRefObject
Implements ISponsor
Private lastRenewal As DateTime
Public Sub New()
lastRenewal = DateTime.Now
End Sub
<SecurityPermission(SecurityAction.LinkDemand, Flags := SecurityPermissionFlag.Infrastructure)> _
Public Function Renewal(lease As ILease) As TimeSpan Implements ISponsor.Renewal
Console.WriteLine("Request to renew the lease time.")
Console.WriteLine("Time since last renewal: " + _
DateTime.op_Subtraction(DateTime.Now, lastRenewal).ToString())
lastRenewal = DateTime.Now
Return TimeSpan.FromSeconds(20)
End Function 'Renewal
End Class
備註
如果物件需要要求特定物件的租用更新,則必須實 ISponsor 作 介面。 實作 ISponsor 介面的物件可以藉由向租用管理員註冊本身來成為贊助者。 存 ISponsor 留期服務會使用 介面來回呼贊助者。
方法
Renewal(ILease) |
要求贊助的用戶端更新指定物件的使用期。 |