public static void Init(Yasuo yas) { Yas = yas; Config = MainMenu.AddMenu("YasuoPro", "YasuoPro"); ComboA = Config.AddSubMenu("Combo"); Combo.Attach(ComboA); HarassA = Config.AddSubMenu("Harass"); Harass.Attach(HarassA); KillstealA = Config.AddSubMenu("Killsteal"); Killsteal.Attach(KillstealA); FarmingA = Config.AddSubMenu("LastHitting"); Farm.Attach(FarmingA); WaveclearA = Config.AddSubMenu("Waveclear"); Waveclear.Attach(WaveclearA); MiscA = Config.AddSubMenu("Misc"); Misc.Attach(MiscA); DrawingsA = Config.AddSubMenu("Drawings"); Drawings.Attach(DrawingsA); Flee = Config.AddSubMenu("Flee Settings", "Flee"); Flee.Add("Flee.Mode", new ComboBox("Flee Mode", 0, "To Nexus", "To Allies", "To Cursor")); Flee.Add("Flee.StackQ", new CheckBox("Stack Q during Flee")); Flee.Add("Flee.UseQ2", new CheckBox("Use Tornado", false)); }
protected void Page_Load(object sender, EventArgs e) { var fac = WcfChannelFactoryFactory.CreateChannelFactory <IActiveRecordConnection <Farm> >(new WcfClientEndpoint { Address = "http://localhost:2166/FarmConnectionService.svc", BindingXml = new BindingXml("basichttpbinding", null), ServiceContractType = typeof(IActiveRecordConnection <Farm>).FullName }); using (var svc = new WcfChannelWrapper <IActiveRecordConnection <Farm> >(fac.CreateChannel())) { Farm farm = new Farm(); farm.Attach(svc.Channel); farm.FarmID = 999; farm.FarmAddress = "999"; farm.LoadBalancePath = "999"; farm.Delete(); farm.Save(); var loadFarm = farm.FindOne(farm.GetObjectId()); loadFarm.Delete(); } }
public void TestActiveRecord() { var cmdFactory = new NIntegrate.Data.QueryCommandFactory(); Farm farm = new Farm(); farm.Attach(new ActiveRecordConnection <Farm>(cmdFactory)); //test insert farm.FarmID = 1000; farm.FarmAddress = "Test Farm"; farm.LoadBalancePath = "/TestPath/"; Assert.IsTrue(farm.IsNew()); Assert.AreEqual(true, farm.Save()); Assert.IsFalse(farm.IsNew()); //test find var loadFarm = farm.FindOne(farm.GetObjectId()); Assert.AreEqual(farm.FarmID, loadFarm.FarmID); Assert.AreEqual(farm.FarmAddress, loadFarm.FarmAddress); Assert.AreEqual(farm.LoadBalancePath, loadFarm.LoadBalancePath); //test update farm.LoadBalancePath = "modified"; farm.Save(); var criteria = farm.GetObjectId().ToCriteria(); farm.Save(Farm.Q.Update(Farm.Q.LoadBalancePath.Set("modified2")).Where(Farm.Q.Farm_id == farm.FarmID)); //test find loadFarm = farm.FindOne(farm.GetObjectId()); Assert.AreEqual(farm.FarmID, loadFarm.FarmID); Assert.AreEqual(farm.FarmAddress, loadFarm.FarmAddress); Assert.AreEqual("modified2", loadFarm.LoadBalancePath); farm.LoadBalancePath = "modified2"; //test findMany var loadManyFarms = farm.FindMany(Farm.Q.Select().SortBy(Farm.Q.Farm_id, true)); Assert.IsTrue(loadManyFarms.Count > 0); loadFarm = loadManyFarms.First(f => f.FarmID == farm.FarmID); Assert.AreEqual(farm.FarmAddress, loadFarm.FarmAddress); Assert.AreEqual(farm.LoadBalancePath, loadFarm.LoadBalancePath); var count = farm.Count(Farm.Q.Select().Where(Farm.Q.Farm_id > 0)); Assert.IsTrue(count > 0); //test delete farm.Delete(); Assert.IsTrue(farm.IsNew()); loadFarm = farm.FindOne(farm.GetObjectId()); Assert.IsNull(loadFarm); //test activerecord serialization var serializer = new DataContractSerializer(typeof(Farm)); var stream = new MemoryStream(); serializer.WriteObject(stream, farm); stream.Seek(0, SeekOrigin.Begin); var deserializedFarm = (Farm)serializer.ReadObject(stream); Assert.AreEqual(farm.FarmID, deserializedFarm.FarmID); Assert.AreEqual(farm.FarmAddress, deserializedFarm.FarmAddress); Assert.AreEqual(farm.LoadBalancePath, deserializedFarm.LoadBalancePath); Assert.IsFalse(deserializedFarm.IsAttached()); Assert.IsTrue(deserializedFarm.IsNew()); //test save/delete after deserialization bool caughtExpectedException = false; try { deserializedFarm.Save(); } catch (InvalidOperationException) { caughtExpectedException = true; } Assert.IsTrue(caughtExpectedException); caughtExpectedException = false; try { deserializedFarm.Delete(); } catch (InvalidOperationException) { caughtExpectedException = true; } Assert.IsTrue(caughtExpectedException); deserializedFarm.Attach(new ActiveRecordConnection <Farm>(cmdFactory)); Assert.IsTrue(deserializedFarm.Save()); Assert.AreEqual(1, deserializedFarm.Delete(Farm.Q.Delete(Farm.Q.Farm_id == farm.FarmID))); //test ObjectId serialization var objectId = farm.GetObjectId(); serializer = new DataContractSerializer(typeof(ObjectId <Farm, TestClasses.QueryClasses.Farm>)); stream = new MemoryStream(); serializer.WriteObject(stream, objectId); stream.Seek(0, SeekOrigin.Begin); var deserializedObjectId = (ObjectId <Farm, TestClasses.QueryClasses.Farm>)serializer.ReadObject(stream); Assert.AreEqual(objectId.AutoGenerated, deserializedObjectId.AutoGenerated); }