示例#1
0
 /// <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();
 }
示例#2
0
 /// <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()
     });
 }
示例#3
0
 /// <summary>
 /// 清理资源
 /// </summary>
 protected override void OnDispose()
 {
     IocHelper.DisposeScope();
 }
示例#4
0
 /// <summary>
 /// 生成一个范围
 /// </summary>
 /// <returns></returns>
 public static IDisposable CreateScope()
 {
     IocHelper.CreateScope();
     return(new IocScope());
 }