Exemple #1
0
 /// <summary>
 /// 初始化环境,3.5 使用
 /// </summary>
 /// <param name="types">需要初始化调用的静态类</param>
 public void Init(IEnumerable <Type> types)
 {
     if (_inited)
     {
         return;
     }
     current         = this;
     container       = new ValuesContainer();
     _modules        = new Modules.Modules(this);
     cycleCollection = new RecyclableObjectCollection();
     if (types != null)
     {
         foreach (var type in types)
         {
             TypeAttributes ta = type.Attributes;
             if ((ta & TypeAttributes.Abstract) != 0 && ((ta & TypeAttributes.Sealed) != 0))
             {
                 RuntimeHelpers.RunClassConstructor(type.TypeHandle);
             }
         }
     }
     _loom   = LoomModule.CreatInstance <LoomModule>("");
     _time   = new TimeCalculator();
     _inited = true;
 }
        /// <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();
        }