private static async Task ListPerson4(helloMessage.helloMessageClient client) { using (var call = client.ListPerson4()) { var tastResponse = Task.Run(async() => { var responseStream = call.ResponseStream; CancellationToken can = new CancellationToken(); while ((await responseStream.MoveNext(can))) { Persion model = responseStream.Current; Console.WriteLine($"Response Name:{model.Name}"); } }); foreach (var i in new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }) { var model = new Persion() { Name = "IN" + i }; Console.WriteLine($"Request Name={model.Name}"); await call.RequestStream.WriteAsync(model); } await call.RequestStream.CompleteAsync(); tastResponse.Wait(); } }
//目的测试怎样获得一个类的所有成员名字 public IActionResult Index() { Persion ob = new Persion(); GetClassMemberName(ob); return(View()); }
private static async void RunTaskList(Persion persion) { PintInfo($"Start {persion.Name,3}"); await Task.Delay(1); // Task dừng 1s - rồi mới chạy tiếp PintInfo($"Finish {persion.Name,3}"); }
public static void ZhuanHuan(Persion per) { if (per is Student) { ((Student)per).StudentSay(); } else if (per is Teacher) { ((Teacher)per).TeacherSay(); } else if (per is Meinv) { ((Meinv)per).MeinvSay(); } else if (per is ShuaiGuo) { ((ShuaiGuo)per).ShuaiGuoSay(); } else if (per is YeShou) { ((YeShou)per).YeShouSay(); } else { per.PersonSay(); } }
public static bool Insert(Persion persion) { using (var context =db.Context()) { return context.Insert<Persion>("Persion", persion) .Execute() > 0; } }
private void btn_search_Click(object sender, EventArgs e) { if (tb_condation.Text == "") { MessageBox.Show("Error input"); return; } this.dataGridView1.DataSource = Persion.search("P_" + this.cb_type.SelectedItem.ToString(), this.tb_condation.Text); }
public void SavePersion(Persion persion) { using (var session = SessionFactoryHandler.OpenSession()) { using (var transaction = session.BeginTransaction()) { session.Save(persion); session.Flush(); transaction.Commit(); } } }
public void set_Persion(Persion P) { this.tb_ID.Text = P.ID; this.tb_Name.Text = P.Name; this.cb_gender.Text = P.Sex; this.dt_birthday.Value = P.Birthday; this.dt_jobday.Value = P.Jobday; this.cb_education.Text = P.Education; this.cb_department.Text = P.Department; this.cb_duty.Text = P.Duty; this.cb_jobType.Text = P.Jobtype; this.Display_index = P.index; }
private void btn_update_Click(object sender, EventArgs e) { Persion P = get_persion(); P.index = this.Display_index; bool res = P.update_by_index(); if (res == false) { MessageBox.Show("data wrong"); } this.refreash_grid(); }
public List <string> GetClassMemberName(Persion sb) { List <string> _memberlist = new List <string>(); Type t = sb.GetType(); foreach (PropertyInfo pi in t.GetProperties()) { //var st = pi.GetValue(sb, null);可以获得对应的值 string name = pi.Name; } return(_memberlist); }
public override async Task ListPerson2(Persion request, IServerStreamWriter <Persion> responseStream, ServerCallContext context) { //return base.ListPerson2(request, responseStream, context); Console.WriteLine($"Person:{request.Name}."); foreach (var i in Enumerable.Range(0, 10)) { await responseStream.WriteAsync(new Persion() { Name = "A" + DateTime.Now.Second.ToString() }); Thread.Sleep(1000); } }
public void UpdatePersion(Persion persion) { using (var session = SessionFactoryHandler.OpenSession()) { using (var transaction = session.BeginTransaction()) { //model.Name = persion.Name; //model.Age = persion.Age; session.Update(persion); session.Flush(); transaction.Commit(); } } }
public void DeleteById(int id) { using (var session = SessionFactoryHandler.OpenSession()) { using (var transaction = session.BeginTransaction()) { Persion p1 = new Persion(); p1.Id = id; session.Delete(p1); session.Flush(); transaction.Commit(); } } }
public ActionResult Create(Persion persion) { if (persion == null) { throw new NullReferenceException("Persion"); } if (string.IsNullOrWhiteSpace(persion.Name)) { throw new NullReferenceException("Persion.Name"); } sfm.SavePersion(persion); return(Redirect("/Home/Index")); }
private static async Task ListPerson2(helloMessage.helloMessageClient client) { using (var call = client.ListPerson2(new Persion() { Name = "B" })) { var responseStream = call.ResponseStream; CancellationToken can = new CancellationToken(); while ((await responseStream.MoveNext(can))) { Persion model = responseStream.Current; Console.WriteLine($"Name:{model.Name}"); } } }
public void Test004() { // Action<string> ask = new Action<string>(LambdaRunner.<>c.<>9.<Test004>b__8_0); Action <string> action = (quen) => { Console.WriteLine("The answer to `" + quen + "` is certainly 42!"); }; //Create anonymous object var person = new { Name = "Jesse", Age = 28, //错误 CS0828 无法将 lambda 表达式 赋予匿名类型属性 DelegateLambda Ask = action }; var p2 = new Persion(); //Execute function //person.Ask("Why are you doing this?"); }
private void dgv_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridView d = (DataGridView)sender; Persion p = new Persion( d.Rows[e.RowIndex].Cells[0].Value.ToString(), d.Rows[e.RowIndex].Cells[1].Value.ToString(), d.Rows[e.RowIndex].Cells[2].Value.ToString(), DateTime.Parse(d.Rows[e.RowIndex].Cells[3].Value.ToString()), DateTime.Parse(d.Rows[e.RowIndex].Cells[4].Value.ToString()), d.Rows[e.RowIndex].Cells[5].Value.ToString(), d.Rows[e.RowIndex].Cells[6].Value.ToString(), d.Rows[e.RowIndex].Cells[7].Value.ToString(), d.Rows[e.RowIndex].Cells[8].Value.ToString() ); p.update_index(); this.set_Persion(p); }
protected override void OnStartup(StartupEventArgs e) { for (int i = 0; i < 20; i++) { Persion persion = new Persion(); Debug.WriteLine(persion.Card); } if (e.Args != null) { foreach (var item in e.Args) { MessageBox.Show(item); } } base.OnStartup(e); }
static void Main(string[] args) { var point = new Point(); //Không thể sử dụng point.X && Point.Y vì X; Y là private var poin2 = new Point(100, 200); poin2.GetPoint(); // GetPoint có thuộc tính public nên không hạn chế quyền truy cập var persion = new Persion(2, "Vu Duc Cuong"); //Không truy cập được vào GetPersionInfo() vì đang có thuộc tính protected var getset = new GetSet(); getset.MyText = "Ha ha"; Console.WriteLine(getset.MyText); Console.WriteLine("Hello World!"); }
static void Main(string[] args) { Random rm = new Random(); Persion[] pers = new Persion[10]; for (int i = 0; i < pers.Length; i++) { int rNumber = rm.Next(1, 7); switch (rNumber) { case 1: pers[i] = new Student(); break; case 2: pers[i] = new Teacher(); break; case 3: pers[i] = new Meinv(); break; case 4: pers[i] = new ShuaiGuo(); break; case 5: pers[i] = new YeShou(); break; case 6: pers[i] = new Persion(); break; } } for (int i = 0; i < pers.Length; i++) { ZhuanHuan(pers[i]); } Console.ReadKey(); }
public ActionResult Edit(Persion persion) { if (persion == null) { throw new NullReferenceException("Persion"); } Persion model = sfm.GetPersionById(persion.Id); if (model == null) { throw new NullReferenceException("Persion.Id"); } model.Name = persion.Name; model.Age = persion.Age; sfm.UpdatePersion(model); return(Redirect("/Home/Index")); }
private void refreash_grid() { this.dgv.DataSource = Persion.RefreashTable(); }
public ActionResult Edit(int id) { Persion model = sfm.GetPersionById(id); return(View(model)); }
protected override void Init() { this.Collection = Persion.Create().ToObservable(); }
//传递单个对象(Josn对象!=Json字符串) public IActionResult SingleObject(Persion per) { string _res = Newtonsoft.Json.JsonConvert.SerializeObject(per); return(Json(_res)); }
public bool Equals(Person p1, Persion p2) { return(p1.Name == p2.Name); }
public static bool Delete(Persion persion) { return Delete(); }
public static bool Update(Persion persion) { using (var context = db.Context()) { return context.Update<Persion>("Persion", persion) .AutoMap(x => ) .Execute() > 0; } }