Ejemplo n.º 1
0
        /// <summary>
        /// 释放
        /// </summary>
        public void Dispose()
        {
            if (_disposed || !haveInit)
            {
                return;
            }
            if (onDispose != null)
            {
                onDispose();
            }
            sw_init.Stop();
            sw_delta.Stop();

            container.Dispose();
            cyclePool.Dispose();

            _disposed = true;
            container = null;
            sw_delta  = null;
            sw_init   = null;
            _modules  = null;
            onInit    = null;
            update    = null;
            onDispose = null;
        }
        /// <summary>
        /// 释放
        /// </summary>
        protected override void OnDispose()
        {
            base.OnDispose();
            if (disposed || !haveInit)
            {
                return;
            }

            cycleCollection.Dispose();
            container.Dispose();
            bindHandler.Dispose();
            if (onDispose != null)
            {
                onDispose();
            }
            sw_init.Stop();
            sw_delta.Stop();

            container = null;
            sw_delta  = null;
            sw_init   = null;
            _modules  = null;
            onInit    = null;
            update    = null;
            onDispose = null;
        }
Ejemplo n.º 3
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();
        }