예제 #1
0
        public PoolItem(string sessionId, string keyId, ref Basics.Dss.IDss reservation)
        {
            this.SessionId = sessionId;
            this.KeyId     = keyId;

            this._Reservation = reservation;
        }
예제 #2
0
        private bool Get(string uniqueId, out Basics.Dss.IDss reservationObject)
        {
            reservationObject = null;

            if (string.IsNullOrEmpty(uniqueId))
            {
                return(false);
            }

            if (!this._ReservationTable.TryGetValue(uniqueId, out reservationObject))
            {
                return(false);
            }

            if (((IService)reservationObject).IsExpired)
            {
                this._ReservationTable.TryRemove(uniqueId, out _);

                reservationObject = null;
                return(false);
            }

            ((IService)reservationObject).Extend();

            return(true);
        }
예제 #3
0
        private void Create(string uniqueId, short reservationTimeout, out Basics.Dss.IDss reservationObject)
        {
            if (string.IsNullOrEmpty(uniqueId))
            {
                throw new Exceptions.ReservationCreationException();
            }

            reservationObject =
                new Service(uniqueId, reservationTimeout);
            this._ReservationTable.TryAdd(uniqueId, reservationObject);
        }
예제 #4
0
        public bool Reserve(string uniqueId, short reservationTimeout, out Basics.Dss.IDss reservationObject)
        {
            lock (this._ReservationLock)
            {
                if (this.Get(uniqueId, out reservationObject))
                {
                    return(true);
                }

                this.Create(uniqueId, reservationTimeout, out reservationObject);
            }

            return(false);
        }
예제 #5
0
        private bool GetReservationObject(ref BinaryReader responseReader, out Basics.Dss.IDss reservationObject)
        {
            reservationObject = null;

            byte uniqueIdLength = responseReader.ReadByte();

            if (uniqueIdLength == 0)
            {
                return(false);
            }

            string uniqueId =
                new string(responseReader.ReadChars(uniqueIdLength));

            return(this._Manager.Reserve(uniqueId, 0, out reservationObject));
        }
예제 #6
0
 public ReservationEnclosure(string sessionId, ref Basics.Dss.IDss reservation)
 {
     this.SessionId    = sessionId;
     this._Reservation = reservation;
 }