Пример #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());
 }