private static void ReleaseLeasable(object instance) { if (instance == null) { return; } if (instance is OperationResponse) { ReleaseCacheEntry(((OperationResponse)instance).SerializablePayload); return; } ILeasable leasable = instance as ILeasable; //for atomic if (leasable != null) { leasable.MarkFree(NCModulesConstants.Global); } else if (instance is IDictionary) //for bulk { foreach (object value in ((IDictionary)instance).Values) { leasable = value as ILeasable; if (leasable != null) { leasable.MarkFree(NCModulesConstants.Global); } } } }
/// <summary> /// Dispose the lease. No need to implement the dispose pattern since this just release the lease and is sealed /// </summary> public void Dispose() { if (this.leasable != null) { Debug.Assert(this.DataObject != null); this.leasable.Release(); this.leasable = null; this.DataObject = null; } }
public int CalculateLease(int id) { ILeasable property = _leasableRepository.GetLeasable(id); Type type = property.GetType(); if (_calculations.TryGetValue(type, out var calculation)) { return(calculation(property)); } throw new Exception("Unexpected type, please extend the calculator"); }
/// <summary> /// Initializes a new LifeTimeWrapper /// </summary> /// <param name="leasable">lease object</param> public AutoLease(ILeasable <T> leasable) { if (leasable == null) { throw new ArgumentNullException(nameof(leasable)); } this.leasable = leasable; // Try to acquire a lease on the leasable object, and renew if necessary this.DataObject = this.leasable.Acquire(); }
public void ShowLeasingCharges(int id) { leasable = leasableRepository.GetLeasable(id); var leasingCharge = GetLeasingCharges((T)leasable); }
public static int GetLeasingCharges(ILeasable leasable) => leasable is ClubHouse x