| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 | 
							- using System;
 
- using System.Collections.Concurrent;
 
- using System.Linq.Expressions;
 
- using System.Threading;
 
- namespace WCS.Core
 
- {
 
-     public static class Ltc
 
-     {
 
-         private static ConcurrentDictionary<Thread, string> Channels = new ConcurrentDictionary<Thread, string>();
 
-         public static void SetChannel(string channel)
 
-         {
 
-             Channels[Thread.CurrentThread] = channel;
 
-         }
 
-         public static string GetChannel()
 
-         {
 
-             return Channels[Thread.CurrentThread];
 
-         }
 
-         public static void Log(string msg)
 
-         {
 
-             var channel = GetChannel();
 
-             if (channel == "刷新")
 
-             {
 
-                 return;
 
-             }
 
-             DebugPublisher.Publish(GetChannel(), msg);
 
-         }
 
-         private static string ResultString<T>(T obj)
 
-         {
 
-             if (obj == null)
 
-             {
 
-                 return "null";
 
-             }
 
-             else if (obj is bool)
 
-             {
 
-                 var b = obj as Boolean?;
 
-                 return b.Value ? "成立" : "不成立";
 
-             }
 
-             else if (obj is System.Collections.ICollection)
 
-             {
 
-                 var coll = obj as System.Collections.ICollection;
 
-                 return coll.Count.ToString() + "元素";
 
-             }
 
-             return obj.ToString();
 
-         }
 
-         public static T Do<T>(Expression<Func<T>> exp)
 
-         {
 
-             var msg = exp.ExpToString();
 
-             msg += "  结果:";
 
-             try
 
-             {
 
-                 var res = exp.Compile().Invoke();
 
-                 return res;
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 msg += ex.GetBaseException().Message;
 
-                 throw;
 
-             }
 
-             finally
 
-             {
 
-                 Log(msg);
 
-             }
 
-         }
 
-         public static T Do<T1, T>(T1 obj, Expression<Func<T1, T>> exp)
 
-         {
 
-             var msg = "";
 
-             try
 
-             {
 
-                 try
 
-                 {
 
-                     msg = exp.ExpToString();
 
-                 }
 
-                 catch (Exception ex2)
 
-                 {
 
-                 }
 
-                 msg += "  结果:";
 
-                 var res = exp.Compile().Invoke(obj);
 
-                 msg += ResultString(res);
 
-                 return res;
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 msg += ex.GetBaseException().Message;
 
-                 throw;
 
-             }
 
-             finally
 
-             {
 
-                 Log(msg);
 
-             }
 
-         }
 
-         public static T Do<T1, T2, T>(T1 obj, T2 obj2, Expression<Func<T1, T2, T>> exp)
 
-         {
 
-             var msg = exp.ExpToString();
 
-             msg += "  结果:";
 
-             try
 
-             {
 
-                 var res = exp.Compile().Invoke(obj, obj2);
 
-                 msg += ResultString(res);
 
-                 return res;
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 msg += ex.GetBaseException().Message;
 
-                 throw;
 
-             }
 
-             finally
 
-             {
 
-                 Log(msg);
 
-             }
 
-         }
 
-         public static T Do<T1, T2, T3, T>(T1 obj, T2 obj2, T3 obj3, Expression<Func<T1, T2, T3, T>> exp)
 
-         {
 
-             var msg = exp.ExpToString();
 
-             msg += "  结果:";
 
-             try
 
-             {
 
-                 var res = exp.Compile().Invoke(obj, obj2, obj3);
 
-                 msg += ResultString(res);
 
-                 return res;
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 msg += ex.GetBaseException().Message;
 
-                 throw;
 
-             }
 
-             finally
 
-             {
 
-                 Log(msg);
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |