示例#1
0
        /// <summary>
        /// 构造一个非根容器
        /// </summary>
        /// <param name="parent">父容器</param>
        internal RobotCat(RobotCat parent)
        {
            Root = parent.Root;                                      //指向父容器的_root,如果父容器也是非根容器,则继续指向父容器,最后其实指向的就是根容器。即所有非根容器的Root都指向根容器

            RegistryDic  = Root.RegistryDic;                         //愿望清单池指向根容器的愿望清单池,即非根容器没有愿望清单池,向非根容器添加愿望清单,都会存储到根容器的愿望清单池中
            _serviceDic  = new ConcurrentDictionary <Key, object>(); //持久化服务实例存储在当前容器中
            _disposables = new ConcurrentBag <IDisposable>();        //可释放实例存在在当前容器中
        }
示例#2
0
        /// <summary>
        /// 构造一个根容器
        /// </summary>
        public RobotCat()
        {
            Root = this;//自己就是根容器,没有父容器,指向自己

            RegistryDic  = new ConcurrentDictionary <Type, ServiceRegistry>();
            _serviceDic  = new ConcurrentDictionary <Key, object>();
            _disposables = new ConcurrentBag <IDisposable>();
        }