Ejemplo n.º 1
0
        public PoolItem(string sessionId, string keyId, ref Basics.Dss.IDss reservation)
        {
            this.SessionId = sessionId;
            this.KeyId     = keyId;

            this._Reservation = reservation;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 6
0
 public ReservationEnclosure(string sessionId, ref Basics.Dss.IDss reservation)
 {
     this.SessionId    = sessionId;
     this._Reservation = reservation;
 }