public Form1() { InitializeComponent(); calc = new Calc(); //operations = new List<IOperation>(); //Assembly asm = Assembly.GetExecutingAssembly(); //var types = asm.GetTypes(); //var typeOperation = typeof(IOperation); //foreach (var item in types.Where(t => !t.IsAbstract && !t.IsInterface)) //{ // if (item.GetInterfaces().Any(t => t == typeOperation)) // { // var obj = Activator.CreateInstance(item); // var operation = obj as IOperation; // if (operation != null) operations.Add(operation); // } //} cbOperation.Items.Clear(); cbOperation.Items.AddRange(calc.GetOperationsName()); cbOperation.Text = cbOperation.Items[0].ToString(); var history = Repository.GetAll(); foreach (var historyItem in history) { tbHistory.AppendText($"{historyItem.NameOperation}({historyItem.Args}) = {historyItem.Result} | {historyItem.Time}\r\n"); } }
// GET: Operation public ActionResult Index() { var operationRepository = new NHBaseRepository <Operation>(); var dbOperations = operationRepository.GetAll(); var operations = dbOperations.Select(o => new OperationViewModel() { Id = o.Id, Name = o.Name, OwnerId = o.Owner.Id }); return(View(operations)); }
public Form1() { InitializeComponent(); calc = new Calc(); Repository = new NHBaseRepository(); cb_Operation.Items.Clear(); cb_Operation.Items.AddRange(calc.GetOperationsName()); cb_Operation.Text = cb_Operation.Items[0].ToString(); // получаем из базы всю историю var history = Repository.GetAll(); foreach (var historyItem in history) { tb_History.AppendText($"{historyItem.NameOperation}({historyItem.Args})={historyItem.Result} | {historyItem.Time}\r\n"); } }
private void btn_Exec_Click(object sender, EventArgs e) { var str = tb_Input.Text.Trim(' '); if (string.IsNullOrEmpty(str)) { tb_Result.Text = "Не успех"; return; } var args = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(s => Convert.ToDouble(s)).ToArray(); var result = calc.Exec(cb_Operation.Text, args); tb_Result.Text = result.ToString(); // сохраняем в базу HistoryItem item = new HistoryItem(); item.Args = str; item.NameOperation = cb_Operation.Text; item.Time = DateTime.Now; item.Result = (float)result; item.Id = 10; Repository.Save(item); // получаем из базы всю историю var history = Repository.GetAll(); tb_History.Clear(); foreach (var historyItem in history) { tb_History.AppendText($"{historyItem.NameOperation}({historyItem.Args})={historyItem.Result} | {historyItem.Time}\r\n"); } }