/// <summary> /// 清理资源 /// </summary> protected override void OnDispose() { if (DisposeFunc != null) { foreach (var func in DisposeFunc) { try { func(); } catch (Exception e) { Console.WriteLine(e); } } Local.Value = null; } try { IocHelper.DisposeScope(); _scope.Dispose(); } catch (Exception e) { Console.WriteLine(e); } GC.Collect(); }
/// <summary> /// 生成一个范围 /// </summary> /// <returns></returns> public static IDisposable CreateScope(string name = null) { Local.Value = new LocalValueType(name ?? "Scope", new DependencyObjects(), new List <Action>(), IocHelper.Create <ILoggerFactory>().CreateLogger(name ?? "Log")); return(new IocScope { _scope = IocHelper.CreateScope() }); }
/// <summary> /// 清理资源 /// </summary> protected override void OnDispose() { IocHelper.DisposeScope(); }
/// <summary> /// 生成一个范围 /// </summary> /// <returns></returns> public static IDisposable CreateScope() { IocHelper.CreateScope(); return(new IocScope()); }