public MyVal Clone(MyVal obj) { return new MyVal { id = obj.id, SomeVal = obj.SomeVal } }
private void btnEvaluate_Click(object sender, EventArgs e) { MyVal <double> x = new MyVal <double>(); x.Value = 3.3; dynamic myt = Activator.CreateInstance(CreateAnonymousType <double, MyVal <double> >("Val1", "Val2")); myt.Val2 = x; myt.Val1 = 1.0; object result = null; try { result = SnowLib.Scripting.SimpleExpressionParser.GetValue(this.tbExpression.Text, myt); } catch (SnowLib.Scripting.SimpleExpressionException see) { if (see.Position >= 0) { this.tbExpression.Select(see.Position, see.Length); this.tbExpression.Focus(); } this.tbResult.ForeColor = Color.Red; this.tbResult.Text = see.Message; return; } catch (Exception ex) { this.tbResult.ForeColor = Color.Red; this.tbResult.Text = ex.Message; return; } this.tbResult.ForeColor = SystemColors.WindowText; this.tbResult.Text = Convert.ToString(result); /*SqlConnection connection = new SqlConnection( * @"Data Source=SQLTAG\SQL2008;Initial Catalog=IsupDB;Integrated Security=False;User ID=;Password=;Network Library=dbmssocn;Packet Size=4096"); * ISqlProcedures isql = SqlCommandProxy<ISqlProcedures>.Create(connection);*/ //int x = 0; //int rv = isql.Test(1, "aaa", out x); //DataTable dt = isql.GetUsers(null); //sp. /*long ticks = Environment.TickCount; * DbContext s = new DbContext(); * for (int i = 0; i < 1000000; i++) * { * s.Read(i, i.ToString()); * } * ticks = Environment.TickCount - ticks; * this.Text = ticks.ToString();*/ /* object result; * try * { * result = SnowLib.Scripting.SimpleExpressionParser.GetValue(this.tbExpression.Text, null); * * } * catch(SnowLib.Scripting.SimpleExpressionException see) * { * if (see.Position >= 0) * { * this.tbExpression.Select(see.Position, see.Length); * this.tbExpression.Focus(); * } * this.tbResult.ForeColor = Color.Red; * this.tbResult.Text = see.Message; * return; * } * catch(Exception ex) * { * this.tbResult.ForeColor = Color.Red; * this.tbResult.Text = ex.Message; * return; * * } * this.tbResult.ForeColor = SystemColors.WindowText; * this.tbResult.Text = Convert.ToString(result);*/ }
public bool Equals(MyVal other) => Value == other.Value;