Пример #1
0
        public void Recycle(ECS_Disposer obj)
        {
            Type type = obj.GetType();
            ECS_Queue <ECS_Disposer> queue;

            if (!this.dictionary.TryGetValue(type, out queue))
            {
                queue = new ECS_Queue <ECS_Disposer>();
                this.dictionary.Add(type, queue);
            }
            queue.Enqueue(obj);
        }
Пример #2
0
        public ECS_Disposer Fetch(Type type)
        {
            ECS_Queue <ECS_Disposer> queue;

            if (!this.dictionary.TryGetValue(type, out queue))
            {
                queue = new ECS_Queue <ECS_Disposer>();
                this.dictionary.Add(type, queue);
            }
            ECS_Disposer obj;

            if (queue.Count > 0)
            {
                obj    = queue.Dequeue();
                obj.Id = IdGenerater.GenerateId();
                return(obj);
            }
            obj = (ECS_Disposer)Activator.CreateInstance(type);
            return(obj);
        }