Exemple #1
0
        /// <summary>
        /// 初始化环境,3.5 使用
        /// </summary>
        /// <param name="types">需要初始化调用的静态类</param>
        public void Init(IEnumerable <Type> types)
        {
            if (_haveInit)
            {
                return;
            }

            container = new FrameworkContainer();
            _modules  = new FrameworkModules(this);
            cyclePool = new RecyclableObjectPool();
            if (types != null)
            {
                types.ForEach((type) =>
                {
                    TypeAttributes ta = type.Attributes;
                    if (ta.HasFlag(TypeAttributes.Abstract) && ta.HasFlag(TypeAttributes.Sealed))
                    {
                        RuntimeHelpers.RunClassConstructor(type.TypeHandle);
                    }
                });
            }

            if (onInit != null)
            {
                onInit();
            }
            deltaTime = TimeSpan.Zero;
            _disposed = false;
            _haveInit = true;
            sw_delta  = new Stopwatch();
            sw_init   = new Stopwatch();
            sw_init.Start();
        }
        /// <summary>
        /// 初始化环境,3.5 使用
        /// </summary>
        /// <param name="types">需要初始化调用的静态类</param>
        public void Init(IEnumerable <Type> types)
        {
            if (_haveInit)
            {
                return;
            }
            currentEnv = this;

            bindHandler     = new BindableObjectHandler();
            container       = new FrameworkContainer();
            _modules        = new FrameworkModules(this);
            cycleCollection = new RecyclableObjectCollection();
            if (types != null)
            {
                types.ForEach((type) =>
                {
                    TypeAttributes ta = type.Attributes;
                    if ((ta & TypeAttributes.Abstract) != 0 && ((ta & TypeAttributes.Sealed) != 0))
                    {
                        RuntimeHelpers.RunClassConstructor(type.TypeHandle);
                    }
                });
            }

            if (onInit != null)
            {
                onInit();
            }
            deltaTime = TimeSpan.Zero;
            _haveInit = true;
            sw_delta  = new Stopwatch();

            sw_init = new Stopwatch();
            sw_init.Start();
        }