public bool ThrowGadgetEquipped() { if (currentGadget) { if (currentGadget.GetType() == typeof(GadgetThrow)) { return(true); } } return(false); }
public void Populate(Gadget gadget) { //Use reflection go copy all of the fields from the Gadget Object to the Gadget2 object foreach (var prop in gadget.GetType().GetProperties()) { this.GetType().GetProperty(prop.Name).SetValue(this, prop.GetValue(gadget, null), null); } //Format date on the Server instead of in the javascript this.UpdateDateTimeString = gadget.UpdatedDateTime.ToString(); }
static void Main(string[] args) { object x = new Gadget(); Type t = x.GetType(); MethodInfo mi = t.GetMethod("FizzBuzz"); object returnedValue = mi.Invoke(x, new object[] { 10, 101 }); IList <int> returnedList = (IList <int>)returnedValue; string msg = returnedList.Select(n => n.ToString(CultureInfo.InvariantCulture)).Aggregate((s, v) => string.Format("{0}...{1}", s, v)); Console.WriteLine(msg); return; }
public void InsertGadget(Gadget gadget) { gadget.gameObject.name = gadget.GetType().ToString() + gadgetsInWorld.Count.ToString(); gadgetsInWorld.Add(gadget); MarkWorldModified(); }