Compartir vía


ISponsor Interfaz

Definición

Indica que el implementador desea ser un patrocinador de concesiones de período de duración.

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
Derivado
Atributos

Ejemplos

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

Comentarios

Un objeto debe implementar la ISponsor interfaz si necesita solicitar una renovación de concesión para un objeto determinado. Un objeto que implementa la ISponsor interfaz puede convertirse en un patrocinador registrándose con el administrador de concesiones. El ISponsor servicio de duración utiliza la interfaz para volver a llamar al patrocinador.

Métodos

Renewal(ILease)

Solicita un cliente patrocinador para renovar el período del objeto especificado.

Se aplica a