scripts
This commit is contained in:
@@ -0,0 +1,255 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
|
||||
namespace System.Runtime.Remoting.Lifetime
|
||||
{
|
||||
// Token: 0x020003D1 RID: 977
|
||||
internal class Lease : MarshalByRefObject, ILease
|
||||
{
|
||||
// Token: 0x06002669 RID: 9833 RVA: 0x0007E7C8 File Offset: 0x0007C9C8
|
||||
public Lease()
|
||||
{
|
||||
this._currentState = LeaseState.Initial;
|
||||
this._initialLeaseTime = LifetimeServices.LeaseTime;
|
||||
this._renewOnCallTime = LifetimeServices.RenewOnCallTime;
|
||||
this._sponsorshipTimeout = LifetimeServices.SponsorshipTimeout;
|
||||
this._leaseExpireTime = DateTime.Now + this._initialLeaseTime;
|
||||
}
|
||||
|
||||
// Token: 0x17000730 RID: 1840
|
||||
// (get) Token: 0x0600266A RID: 9834 RVA: 0x0007E81C File Offset: 0x0007CA1C
|
||||
public TimeSpan CurrentLeaseTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._leaseExpireTime - DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000731 RID: 1841
|
||||
// (get) Token: 0x0600266B RID: 9835 RVA: 0x0007E830 File Offset: 0x0007CA30
|
||||
public LeaseState CurrentState
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._currentState;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600266C RID: 9836 RVA: 0x0007E838 File Offset: 0x0007CA38
|
||||
public void Activate()
|
||||
{
|
||||
this._currentState = LeaseState.Active;
|
||||
}
|
||||
|
||||
// Token: 0x17000732 RID: 1842
|
||||
// (get) Token: 0x0600266D RID: 9837 RVA: 0x0007E844 File Offset: 0x0007CA44
|
||||
// (set) Token: 0x0600266E RID: 9838 RVA: 0x0007E84C File Offset: 0x0007CA4C
|
||||
public TimeSpan InitialLeaseTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._initialLeaseTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this._currentState != LeaseState.Initial)
|
||||
{
|
||||
throw new RemotingException("InitialLeaseTime property can only be set when the lease is in initial state; state is " + this._currentState + ".");
|
||||
}
|
||||
this._initialLeaseTime = value;
|
||||
this._leaseExpireTime = DateTime.Now + this._initialLeaseTime;
|
||||
if (value == TimeSpan.Zero)
|
||||
{
|
||||
this._currentState = LeaseState.Null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000733 RID: 1843
|
||||
// (get) Token: 0x0600266F RID: 9839 RVA: 0x0007E8BC File Offset: 0x0007CABC
|
||||
// (set) Token: 0x06002670 RID: 9840 RVA: 0x0007E8C4 File Offset: 0x0007CAC4
|
||||
public TimeSpan RenewOnCallTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._renewOnCallTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this._currentState != LeaseState.Initial)
|
||||
{
|
||||
throw new RemotingException("RenewOnCallTime property can only be set when the lease is in initial state; state is " + this._currentState + ".");
|
||||
}
|
||||
this._renewOnCallTime = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000734 RID: 1844
|
||||
// (get) Token: 0x06002671 RID: 9841 RVA: 0x0007E8FC File Offset: 0x0007CAFC
|
||||
// (set) Token: 0x06002672 RID: 9842 RVA: 0x0007E904 File Offset: 0x0007CB04
|
||||
public TimeSpan SponsorshipTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._sponsorshipTimeout;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this._currentState != LeaseState.Initial)
|
||||
{
|
||||
throw new RemotingException("SponsorshipTimeout property can only be set when the lease is in initial state; state is " + this._currentState + ".");
|
||||
}
|
||||
this._sponsorshipTimeout = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06002673 RID: 9843 RVA: 0x0007E93C File Offset: 0x0007CB3C
|
||||
public void Register(ISponsor obj)
|
||||
{
|
||||
this.Register(obj, TimeSpan.Zero);
|
||||
}
|
||||
|
||||
// Token: 0x06002674 RID: 9844 RVA: 0x0007E94C File Offset: 0x0007CB4C
|
||||
public void Register(ISponsor obj, TimeSpan renewalTime)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (this._sponsors == null)
|
||||
{
|
||||
this._sponsors = new ArrayList();
|
||||
}
|
||||
this._sponsors.Add(obj);
|
||||
}
|
||||
if (renewalTime != TimeSpan.Zero)
|
||||
{
|
||||
this.Renew(renewalTime);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06002675 RID: 9845 RVA: 0x0007E9C4 File Offset: 0x0007CBC4
|
||||
public TimeSpan Renew(TimeSpan renewalTime)
|
||||
{
|
||||
DateTime dateTime = DateTime.Now + renewalTime;
|
||||
if (dateTime > this._leaseExpireTime)
|
||||
{
|
||||
this._leaseExpireTime = dateTime;
|
||||
}
|
||||
return this.CurrentLeaseTime;
|
||||
}
|
||||
|
||||
// Token: 0x06002676 RID: 9846 RVA: 0x0007E9FC File Offset: 0x0007CBFC
|
||||
public void Unregister(ISponsor obj)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (this._sponsors != null)
|
||||
{
|
||||
for (int i = 0; i < this._sponsors.Count; i++)
|
||||
{
|
||||
if (object.ReferenceEquals(this._sponsors[i], obj))
|
||||
{
|
||||
this._sponsors.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06002677 RID: 9847 RVA: 0x0007EA90 File Offset: 0x0007CC90
|
||||
internal void UpdateState()
|
||||
{
|
||||
if (this._currentState != LeaseState.Active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.CurrentLeaseTime > TimeSpan.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this._sponsors != null)
|
||||
{
|
||||
this._currentState = LeaseState.Renewing;
|
||||
lock (this)
|
||||
{
|
||||
this._renewingSponsors = new Queue(this._sponsors);
|
||||
}
|
||||
this.CheckNextSponsor();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._currentState = LeaseState.Expired;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06002678 RID: 9848 RVA: 0x0007EB28 File Offset: 0x0007CD28
|
||||
private void CheckNextSponsor()
|
||||
{
|
||||
if (this._renewingSponsors.Count == 0)
|
||||
{
|
||||
this._currentState = LeaseState.Expired;
|
||||
this._renewingSponsors = null;
|
||||
return;
|
||||
}
|
||||
ISponsor sponsor = (ISponsor)this._renewingSponsors.Peek();
|
||||
this._renewalDelegate = new Lease.RenewalDelegate(sponsor.Renewal);
|
||||
IAsyncResult asyncResult = this._renewalDelegate.BeginInvoke(this, null, null);
|
||||
ThreadPool.RegisterWaitForSingleObject(asyncResult.AsyncWaitHandle, new WaitOrTimerCallback(this.ProcessSponsorResponse), asyncResult, this._sponsorshipTimeout, true);
|
||||
}
|
||||
|
||||
// Token: 0x06002679 RID: 9849 RVA: 0x0007EBA8 File Offset: 0x0007CDA8
|
||||
private void ProcessSponsorResponse(object state, bool timedOut)
|
||||
{
|
||||
if (!timedOut)
|
||||
{
|
||||
try
|
||||
{
|
||||
IAsyncResult asyncResult = (IAsyncResult)state;
|
||||
TimeSpan timeSpan = this._renewalDelegate.EndInvoke(asyncResult);
|
||||
if (timeSpan != TimeSpan.Zero)
|
||||
{
|
||||
this.Renew(timeSpan);
|
||||
this._currentState = LeaseState.Active;
|
||||
this._renewingSponsors = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
this.Unregister((ISponsor)this._renewingSponsors.Dequeue());
|
||||
this.CheckNextSponsor();
|
||||
}
|
||||
|
||||
// Token: 0x04000EF5 RID: 3829
|
||||
private DateTime _leaseExpireTime;
|
||||
|
||||
// Token: 0x04000EF6 RID: 3830
|
||||
private LeaseState _currentState;
|
||||
|
||||
// Token: 0x04000EF7 RID: 3831
|
||||
private TimeSpan _initialLeaseTime;
|
||||
|
||||
// Token: 0x04000EF8 RID: 3832
|
||||
private TimeSpan _renewOnCallTime;
|
||||
|
||||
// Token: 0x04000EF9 RID: 3833
|
||||
private TimeSpan _sponsorshipTimeout;
|
||||
|
||||
// Token: 0x04000EFA RID: 3834
|
||||
private ArrayList _sponsors;
|
||||
|
||||
// Token: 0x04000EFB RID: 3835
|
||||
private Queue _renewingSponsors;
|
||||
|
||||
// Token: 0x04000EFC RID: 3836
|
||||
private Lease.RenewalDelegate _renewalDelegate;
|
||||
|
||||
// Token: 0x020006CF RID: 1743
|
||||
// (Invoke) Token: 0x060041C4 RID: 16836
|
||||
private delegate TimeSpan RenewalDelegate(ILease lease);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user