/// <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> /// 释放 /// </summary> protected override void OnDispose() { if (disposed || !inited) { return; } if (onDispose != null) { onDispose(); } _modules.Dispose(); (cycleCollection as RecyclableObjectCollection).Dispose(); container.Dispose(); _loom.Dispose(); _time.Dispose(); container = null; _modules = null; update = null; onDispose = null; }