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");
        }
Exemple #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();
        }
        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);
        }
Exemple #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...."));
        }
        // 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");
        }
Exemple #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);
        }
        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();
        }
Exemple #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); });
        }
Exemple #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);
        }
Exemple #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));
        }
Exemple #11
0
 public LoggerModule(string moduleName, ShowLog showLog)
 {
     this.moduleName = moduleName;
     this.showLog    = showLog;
 }
Exemple #12
0
 public void SetShowLog(ShowLog showLog)
 {
     this.showLog = showLog;
 }
Exemple #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();
 }
Exemple #15
0
        static void Tong(int a, int b, ShowLog log)
        {
            int result = a + b;

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

        _instance = this;
    }