public static object InvokeStatic(System.Type klass, string name, object variable) { object[] args = (object[]) null; if (variable != null) args = new object[1]{ variable }; return klass.InvokeMember(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod, (Binder) null, (object) null, args, (ParameterModifier[]) null, (CultureInfo) null, (string[]) null); }
public static object InvokeStatic(System.Type klass, string name, object variable) { object[] args = null; if (variable != null) { args = new object[] { variable }; } return klass.InvokeMember(name, BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static, null, null, args, null, null, null); }
public void executeRules(System.Windows.Forms.HtmlElement lnkEncourage, System.Windows.Forms.HtmlElement lnkPunish) { using (SQLiteConnection conn = new SQLiteConnection(@"Data Source=" + dbPath + @"\gv.db;Version=3;New=False;Compress=True;")) { conn.Open(); using (SQLiteCommand cmd = conn.CreateCommand()) { /*, 'localtime'*/ string query = "select HeroName,Name,Active,Action,Minutes,Condition,Comparison,Value,"; query += " (select datetime(max(ActivityDate)) as ActivityDate from RuleAction where RuleName=rd.Name and HeroName=rd.HeroName) as ActivityDate"; query += " from RuleDefinition rd"; query += " where Active='T' and HeroName=@HeroName"; cmd.CommandText = query; cmd.Parameters.AddWithValue("@HeroName", this.Name); cmd.CommandType = CommandType.Text; SQLiteDataAdapter da = new SQLiteDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { DateTime dt1 = DateTime.Parse(String.IsNullOrEmpty(row["ActivityDate"].ToString()) ? DateTime.Now.ToString() : row["ActivityDate"].ToString()); //dt1 = dt1.AddMinutes(-30); DateTime dt2 = DateTime.Now; TimeSpan ts = dt2 - dt1; int minutes = int.Parse(String.IsNullOrEmpty(row["Minutes"].ToString()) ? "0" : row["Minutes"].ToString()); int value = int.Parse(String.IsNullOrEmpty(row["Value"].ToString()) ? "25" : row["Value"].ToString()); if (ts.TotalMinutes >= minutes) { string ruleDesc = String.Format("{0} every {1} minutes if {2} {3} {4}", row["Action"], row["Minutes"], row["Condition"], row["Comparison"], row["Value"]); if (System.Windows.Forms.MessageBox.Show(String.Format("Execute '{0}' ?", ruleDesc), "Execute Rules...", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { int heroValue = this.GodPower; if (row["Condition"].ToString() == "Current Health (%)") { heroValue = (this.Health * 100 / this.MaxHealth); } if (getComparison(row["Comparison"].ToString(), heroValue, value)) { if (row["Action"].ToString() == "Encourage") { if (lnkEncourage != null) lnkEncourage.InvokeMember("click"); } else if (row["Action"].ToString() == "Punish") { if (lnkPunish != null) lnkPunish.InvokeMember("click"); } using (SQLiteCommand cmd2 = conn.CreateCommand()) { string command2Text = "insert into RuleAction (HeroName, RuleName, Action, ActivityDate) values (@HeroName, @RuleName, @Action, @ActivityDate)"; cmd.Parameters.AddWithValue("@HeroName", this.Name); cmd.Parameters.AddWithValue("@RuleName", row["Name"].ToString()); cmd.Parameters.AddWithValue("@Action", row["Action"].ToString()); cmd.Parameters.AddWithValue("@ActivityDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); cmd.CommandText = command2Text; cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); } } } } } } } } }
public object Make(System.Type type, object[] args) { return type.InvokeMember("Make", GetStaticFlags(), null, null, args); }
public object InvokeStatic(System.Type type, string name, object[] args) { return type.InvokeMember(name, GetStaticFlags(), null, null, args); }
public object InvokeInstance(System.Type type, object obj, string name, object[] args) { return type.InvokeMember(name, GetInstanceFlags(), null, obj, args); }