static void Main(string[] args)
        {
            Log     log = new Log();
            ShowLog showLog;


            showLog = log.warning; //Gán phương thức vào Delegate
            showLog("TEST1");      //Thi hành Delegate


            showLog = log.info;
            showLog("TEST2");

            //Chuỗi Delegate
            showLog  = null;
            showLog += log.warning;
            showLog += log.info;
            showLog += log.warning;
            showLog += (x) => { Console.WriteLine(string.Format("===>{0}<===", x)); };
            //Thi hành chuỗi
            showLog("TestLog");



            ShowLog showLog2 = (x) => { Console.WriteLine(string.Format("[{0}]", x)); };
            //Kết hợp Delegate
            ShowLog showlogall = showLog + showLog2;

            showlogall("All LOG");
        }
Example #2
0
        void ShowBitSeq(N6 n, ShowLog dst)
        {
            var bits = BitSeq.bits(n);

            dst.Show($"n={n}, count={bits.Length}");
            dst.Show(RP.PageBreak120);
            root.iter(bits, s => dst.Buffer.AppendFormat("{0} ", s.Format()));
            dst.ShowBuffer();
        }
Example #3
0
        public void Add(ShowLog log)
        {
            StringBuilder sqlBuilder = new StringBuilder()
                                       .Append("insert into {0} (sl_dtime, sl_mac, sl_advid, sl_pic) ")
                                       .Append("values ({1}, '2}', {3}, '{4}')");
            string sql = string.Format(sqlBuilder.ToString(), DatabaseConf.ShowLogTable, log.ShowLogDispTime,
                                       log.ShowLogMacAddr, log.ShowLogAdvId, log.ShowLogPicture);

            db.ExecuteUpdate(sql);
        }
Example #4
0
        public object Get(ShowLog _)
        {
            if (File.Exists("output.log"))
            {
                var file = new FileInfo(Path.Combine(Env.ContentRootPath, "output.log"));
                return(new HttpResult(file, "text/plain"));
            }

            return(HttpError.NotFound("Hmmmmm...."));
        }
Example #5
0
        // Cộng nhiều Delegate
        public static void TestShowLogPlus()
        {
            ShowLog showLog1 = (x) => { Console.WriteLine($"-----{x}-----"); };
            ShowLog showLog2 = Warning;
            ShowLog showLog3 = Info;

            var all = showLog1 + showLog2 + showLog3 + showLog1;

            all("Xin Chào");
        }
Example #6
0
        public ChildPanel(int Num)
        {
            InitializeComponent();

            panelindex = Num;
            showlog    = new ShowLog(this.LogrichTextBox);
            OutPutLog  = showlog.OutputLog;
            string         StartModel = Context.GetInstance().GeneralInformation.TestStartModel;
            StartModelType modeltype  = (StartModelType)(Enum.Parse(typeof(StartModelType), StartModel));

            UpdataPanelInfo(modeltype);
        }
Example #7
0
        static void Main(string[] args)
        {
            Func <int, int, int> Sum;
            ShowLog sooo = null;

            sooo += prin;
            sooo += prin;
            sooo += (x) => { Console.WriteLine("B"); };
            Sum   = sum;

            sooo("a");
            Console.ReadKey();
        }
Example #8
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            LoadNewModulesToMenuItem(context.GeneralInformation.AddNewModules);

            controlform = new ControlCardLogForm();
            showlog     = new ShowLog(controlform.PrintLog);

            string[] ActionFileName = context.GeneralInformation.ActionFileName.Split('|');
            LoadFormAction = RefelectionHelper.CreatRefelectObj <IAction>(ActionFileName[0], ActionFileName[1]);

            LoadFormAction.PrinterLog = showlog.OutputLog;

            LoadFormAction.InitialHardWare();

            Task.Run(() => { LoadFormAction.FixtureReset(ControlCardInfomation.AxisCard); });
        }
Example #9
0
        static void Main(string[] args)
        {
            ShowLog log = null;
            //log = Info;

            //if (log != null)
            //	log("Xin chao");
            //log?.Invoke("Tran Dan");

            //log = Warning;
            //log("Hoc ve delegate");

            //log += Info;
            //log += Info;
            //log += Info;
            //log += Warning;
            //log += Warning;
            //log += Info;

            //log?.Invoke("Son Tung");

            // Action, Func : delegate - generic
            Action action;                              // ~ delegate void Kieu()
            Action <string, int> action1;               // ~ delegate void Kieu(string s, int i);
            Action <string>      action2;               // ~ delegate void Kieu(string)

            action2  = Warning;
            action2 += Info;
            action2?.Invoke("Thong bao tu Action");

            Func <int> func;                                    // ~ delegate int Kieu()
            Func <string, double, string> func1;                // ~ delegate string Kieu(string s, double d)

            Func <int, int, int> tinhToan;                      // ~ delegate int Kieu(int a, int b)
            int a = 5;
            int b = 10;

            tinhToan = new Func <int, int, int>(Tong);
            WriteLine($"Tong la {tinhToan(a, b)}");

            tinhToan = new Func <int, int, int>(Hieu);
            WriteLine($"Hieu la {tinhToan(a, b)}");

            Tong(a, b, Warning);
        }
Example #10
0
        public override Task <InsertScreenshotResponse> InsertScreenhot(InsertScreenhotRequest request, ServerCallContext context)
        {
            InsertScreenshotResponse response = new InsertScreenshotResponse()
            {
                InsertSucc = true
            };
            ShowLog log = new ShowLog
            {
                ShowLogAdvId    = request.ShowLog.AdId,
                ShowLogMacAddr  = request.ShowLog.MacAddr,
                ShowLogDispTime = request.ShowLog.Disptime,
                ShowLogPicture  = request.ShowLog.Picture.ToByteArray()
            };
            ShowLogDao dao = new ShowLogDao();

            dao.Add(log);
            return(Task.FromResult(response));
        }
Example #11
0
 public LoggerModule(string moduleName, ShowLog showLog)
 {
     this.moduleName = moduleName;
     this.showLog    = showLog;
 }
Example #12
0
 public void SetShowLog(ShowLog showLog)
 {
     this.showLog = showLog;
 }
Example #13
0
 /// <summary>
 /// 实例化一个富文本框的控制台输出
 /// </summary>
 /// <param name="showLog">富文本框的日志输出方法</param>
 public RichTextConsole(ShowLog showLog)
 {
     this.showLog = showLog;
 }
 private void ShowLogButton_Click(object sender, EventArgs e)
 {
     ShowLog?.Invoke();
 }
Example #15
0
        static void Tong(int a, int b, ShowLog log)
        {
            int result = a + b;

            log?.Invoke($"Tong la {result}");
        }
Example #16
0
 public void SetShowLog(ShowLog sl)
 {
     _showLog = sl;
 }
Example #17
0
    // Use this for initialization
    private void Awake()
    {
        operationQueue = new LockedQueue <LogOpBean>();

        _instance = this;
    }