Пример #1
0
 public void Remove(ObjectKey key, object value)
 {
     if (this.Items.ContainsKey(key))
     {
         this.Items[key].Remove(value);
     }
 }
Пример #2
0
        public void Add(ObjectKey key, object value)
        {
            if (this.Items.ContainsKey(key) == false)
            {
                this.Items.Add(key, new List<object>());
            }

            this.Items[key].Add(value);
        }
Пример #3
0
 public void AddRange(ObjectKey key,List<object> items)
 {
     if (this.Items.ContainsKey(key))
     {
         this.Items[key].AddRange(items);
     }
     else
     {
         this.Items.Add(key, items);
     }
 }
Пример #4
0
 public void AddRange(ObjectKey key, List <object> items)
 {
     if (this.Items.ContainsKey(key))
     {
         this.Items[key].AddRange(items);
     }
     else
     {
         this.Items.Add(key, items);
     }
 }
Пример #5
0
 public List<object> this[ObjectKey key]
 {
     get
     {
         if (this.Items.ContainsKey(key))
         {
             return this.Items[key];
         }
         else
         {
             return null;
         }
     }
 }
Пример #6
0
 public List <object> this[ObjectKey key]
 {
     get
     {
         if (this.Items.ContainsKey(key))
         {
             return(this.Items[key]);
         }
         else
         {
             return(null);
         }
     }
 }
Пример #7
0
        private IEnumerable <object> ResolveInstances(ObjectKey key)
        {
            var list = this.ObjectPool[key];

            if (list == null)
            {
                list = new List <object>();
                foreach (var instance in ObjectContainer.CreateInstances(key.Type))
                {
                    list.Add(instance);
                }
                this.ObjectPool.AddRange(key, list);
            }


            return(list);
        }
Пример #8
0
        private void RegisterInstance(ObjectKey key, object instance)
        {
            var list = Items[key];

            if (list == null)
            {
                lock (key)
                {
                    list = Items[key];
                    if (list == null)
                    {
                        list = new List <object>();
                        list.Add(instance);
                        Items.AddRange(key, list);
                    }
                }
            }

            list.Add(instance);
        }
Пример #9
0
        private List <object> ResolveInstances(ObjectKey key)
        {
            var list = Items[key];

            if (list == null)
            {
                lock (key)
                {
                    list = Items[key];
                    if (list == null)
                    {
                        list = new List <object>();
                        foreach (var instance in ObjectContainer.CreateInstances(key.Type))
                        {
                            list.Add(instance);
                        }

                        Items.AddRange(key, list);
                    }
                }
            }

            return(Items[key]);
        }
Пример #10
0
        public IEnumerable ResolveAll(Type type, string name)
        {
            var key = new ObjectKey(type, name);

            return(this.ResolveInstances(key));
        }
Пример #11
0
        public IEnumerable ResolveAll(Type type)
        {
            var key = new ObjectKey(type, null);

            return(ResolveInstances(key));
        }
Пример #12
0
        public object Resolve(Type type, string name)
        {
            var key = new ObjectKey(type, name);

            return(ResolveInstances(key).FirstOrDefault());
        }
Пример #13
0
        public void RegisterInstance(Type type, string name, object instance)
        {
            var key = new ObjectKey(type, name);

            this.ObjectPool.Add(key, instance);
        }
Пример #14
0
        public T Resolve <T>(string name)
        {
            var key = new ObjectKey(typeof(T), name);

            return((T)ResolveInstances(key).FirstOrDefault());
        }