Esempio n. 1
0
        public int Allocate(SlotCategory slotCategory)
        {
            this.slotCategory = SlotCategoryFactory.GetSlotCategory(slotCategory);
            int resourceId = this.slotCategory.resourceId;

            this.slotCategory.MarkBusy();
            return(resourceId);
        }
        public void Deallocate(SlotCategory slotCategory, int resourceId)
        {
            switch (slotCategory)
            {
            case SlotCategory.TimeSlot:
                MarkTimeSlotFree(resourceId);
                break;

            case SlotCategory.SpaceSlot:
                MarkSpaceSlotFree(resourceId);
                break;

            default:
                Console.WriteLine("ERROR: attempted to free invalid resource");
                break;
            }
        }
        public int Allocate(SlotCategory slotCategory)
        {
            int resourceId;

            switch (slotCategory)
            {
            case SlotCategory.TimeSlot:
                resourceId = FindFreeTimeSlot();
                MarkTimeSlotBusy(resourceId);
                break;

            case SlotCategory.SpaceSlot:
                resourceId = FindFreeSpaceSlot();
                MarkSpaceSlotBusy(resourceId);
                break;

            default:
                Console.WriteLine("ERROR: Attempted to allocate invalid resource");
                resourceId = INVALID_RESOURCE_ID;
                break;
            }

            return(resourceId);
        }
Esempio n. 4
0
 public void Deallocate(SlotCategory slotCategory, int resourceId)
 {
     this.slotCategory            = SlotCategoryFactory.GetSlotCategory(slotCategory);
     this.slotCategory.resourceId = resourceId;
     this.slotCategory.MarkFree();
 }
Esempio n. 5
0
 public void Deallocate(SlotCategory slotCategory, int resourceId)
 {
     slotCategory.MarkSlotFree(resourceId);
 }
Esempio n. 6
0
        //public enum SlotCategory
        //{
        //    TimeSlot,
        //    SpaceSlot
        //}

        //private static readonly int INVALID_RESOURCE_ID = -1;

        public int Allocate(SlotCategory slotCategory)
        {
            return(slotCategory.FindFreeSlot());
        }