public void CreateAndDisposeParentChildLoop()
            {
                var parent = new Parent { Child = new Child("c") };
                parent.Child.Parent = parent;
                Assert.AreSame(parent, parent.Child.Parent);
                Assert.AreSame(parent.Child, parent.Child.Parent.Child);
                var propertyChanges = new List<string>();
                var changes = new List<EventArgs>();
                var tracker = Track.Changes(parent, ReferenceHandling.Structural);
                tracker.PropertyChanged += (_, e) => propertyChanges.Add(e.PropertyName);
                tracker.Changed += (_, e) => changes.Add(e);
                Assert.AreEqual(0, tracker.Changes);
                CollectionAssert.IsEmpty(propertyChanges);
                CollectionAssert.IsEmpty(changes);

                tracker.Dispose();
                Assert.AreEqual(0, tracker.Changes);
                CollectionAssert.IsEmpty(propertyChanges);
                CollectionAssert.IsEmpty(changes);

                parent.Name += "abc";
                Assert.AreEqual(0, tracker.Changes);
                CollectionAssert.IsEmpty(propertyChanges);
                CollectionAssert.IsEmpty(changes);

                parent.Child.Name += "abc";
                Assert.AreEqual(0, tracker.Changes);
                CollectionAssert.IsEmpty(propertyChanges);
                CollectionAssert.IsEmpty(changes);
            }
Ejemplo n.º 2
0
        public void Test()
        {
            Family family = new Family();
            Child child1 = new Child(1);
            Child child2 = new Child(2);
            Parent parent = new Parent(new List<Child>() {child1, child2});
            family.Add(parent);

            string file = "sandbox.txt";

            try
            {
                File.Delete(file);
            }
            catch
            {
            }

            using (var fs = File.OpenWrite(file))
            {
                Serializer.Serialize(fs, family);
            }
            using (var fs = File.OpenRead(file))
            {
                family = Serializer.Deserialize<Family>(fs);
            }

            System.Diagnostics.Debug.Assert(family != null, "1. Expect family not null, but not the case.");
        }
        public string Add(ParentModelView parent)
        {
            if(ModelState.IsValid)
            {
                int user_id = SessionHandler.GetUserID();

                if (user_id == -1)
                {
                    return (false).ToJSON();
                }
                int school_id = SessionHandler.GetSchoolID();
                Parent s = new Parent()
                {
                    gfirst_name = parent.GardianFirstName,
                    glast_name = parent.GardianLastName,
                    address = parent.Address,
                    phone = parent.Phone,
                    password = parent.Password,
                    school_id = school_id,
                    created_by = user_id,
                    updated_by = user_id,
                    profession = parent.Profession,
                    income = parent.Income,
                    pfirst_name = parent.ParentFirstName,
                    plast_name = parent.ParentLastName,
                    mother_name = parent.MotherName,
                    landline = parent.Landline,
                    cnic = parent.CNICNumber,
                    email = parent.EmailAddress
                };
                bool result = _pd.Insert(s);
                return result.ToJSON();
            }
            return "";
        }
Ejemplo n.º 4
0
 public void TypeEqualityIsRespected()
 {
     var parent = new Parent().GetChangeType();
     var child = new Child().GetChangeType();
     Assert.IsTrue(parent.IsA(typeof(Parent)));
     Assert.IsTrue(child.IsA(typeof(Child)));
 }
 public void SetUp()
 {
     this._parent = new Parent();
     this._child = new Child();
     this._parent.Child = this._child;
     this._child.Parent = this._parent;
 }
 public void IfNullCreateSetsPropertyAndReturnsCorrectValueIfChildIsNull()
 {
     var parent = new Parent();
     var candidate = parent.IfNullCreate(t => t.Child, () => new Child());
     Assert.IsNotNull(candidate);
     Assert.AreSame(candidate, parent.Child);
 }
 protected override void LoadTestData()
 {
     var parent = new Parent("Mike Hadlow", string.Format("{0}@yahoo.com", "mike"), "yyy");
     Session.Save(parent);
     this.FlushSessionAndEvict(parent);
     parentId = parent.Id;
 }
 protected override void LoadTestData()
 {
     User user = new Parent("Dad", "*****@*****.**", "xxx");
     Session.Save(user);
     this.FlushSessionAndEvict(user);
     userId = user.Id;
 }
            public void ParentChildCreateWhenParentDirtyLoop()
            {
                var changes = new List<string>();
                var expectedChanges = new List<string>();
                var x = new Parent { Name = "p1", Child = new Child("c") };
                x.Child.Parent = x;
                var y = new Parent { Name = "p2", Child = new Child("c") };
                y.Child.Parent = y;
                using (var tracker = Track.IsDirty(x, y, ReferenceHandling.Structural))
                {
                    tracker.PropertyChanged += (_, e) => changes.Add(e.PropertyName);

                    Assert.AreEqual(true, tracker.IsDirty);
                    CollectionAssert.IsEmpty(changes);
                    var expected = "Parent Child Parent ... Name x: p1 y: p2";
                    var actual = tracker.Diff.ToString("", " ");
                    Assert.AreEqual(expected, actual);

                    x.Name = y.Name;
                    y.Name = x.Name;
                    expectedChanges.Add("Diff", "IsDirty");
                    CollectionAssert.AreEqual(expectedChanges, changes);
                    Assert.AreEqual(false, tracker.IsDirty);
                }
            }
Ejemplo n.º 10
0
	//InvokeAdjacent is a recursive function for the reconnection of adjacent blocks to current ship parent
	//(and the setup that comes with that)
	public void InvokeAdjacent(int NewShipID)
	{
		ShipID = NewShipID;
		GameObject tParent = GameObject.Find ("Parent " + NewShipID.ToString ());
		//if there is no parent with this ShipID, make one
		if (tParent == null) {
			ParentTrans = Instantiate (bc.Parent, transform.position, Quaternion.identity) as Transform;
			Parent = ParentTrans.GetComponent<Parent>();
			Parent.ShipID = NewShipID;
			Parent.bc = bc;
			ParentTrans.name = "Parent " + NewShipID.ToString ();
		}
		//join the ship with the ID
		else 
		{
			ParentTrans = tParent.transform;
			Parent = ParentTrans.GetComponent<Parent>();
		}
		transform.parent = ParentTrans;
		//Make the other blocks adjacent to this one do this process (recursive)
		for(int i = 0;i < 4;i++)
		{
			Block thisCheck = CheckAdjacent(i);
			if(thisCheck != null && thisCheck.ShipID != NewShipID)
			{
				thisCheck.InvokeAdjacent(NewShipID);
			}
		}
	}
Ejemplo n.º 11
0
    public override void Poke(Parent parent)
    {
        base.Poke (parent);

        tree.actions.SetSpeed(speed);
        parent.ReceiveStatus(Status.Success);
    }
 public void Test()
 {
     var p = new Parent { Child = new Child() };
     p.Child.A = 1;
     var json = p.ToJson();
     BsonSerializer.Deserialize<Parent>(json); // throws Unexpected element exception
 }
Ejemplo n.º 13
0
 public void InheritanceIsRespected()
 {
     var parent = new Parent().GetChangeType();
     var child = new Child().GetChangeType();
     Assert.IsFalse(parent.IsA(typeof(Child)));
     Assert.IsTrue(child.IsA(typeof(Parent)));
 }
        public void SetUp()
        {
            parent = new Parent
            {
                Id = 10,
                Name = "Parent from repository",
                Child = new Child
                {
                    Id = 3,
                    Name = "Child of Parent from repository"
                }
            };

            parentRepository = new FakeRepository(id => parent);
            childRepository = new FakeRepository(id => parent.Child);

            repositoryResolver = MockRepository.GenerateStub<IRepositoryResolver>();
            repositoryResolver.Stub(r => r.GetRepository(typeof (Parent))).Return(parentRepository);
            repositoryResolver.Stub(r => r.GetRepository(typeof (Child))).Return(childRepository);

            entityModelBinder = new EntityModelBinder(repositoryResolver);
            controllerContext = new ControllerContext
            {
                HttpContext = MockRepository.GenerateStub<HttpContextBase>()
            };
            request = MockRepository.GenerateStub<HttpRequestBase>();
            controllerContext.HttpContext.Stub(x => x.Request).Return(request);

            entityModelBinder.SetModelBinderDictionary(new ModelBinderDictionary { DefaultBinder = entityModelBinder });
        }
Ejemplo n.º 15
0
 protected override void LoadTestData()
 {
     var parent = new Parent(name: "Mike Hadlow", userName: string.Format("{0}@yahoo.com", "mike"), password: "******");
     session.Store(parent);
     parentId = parent.Id;
     this.FlushSessionAndEvict(parent);
 }
        public void PropertyAccessorAccessibilityTest()
        {
            Parent parent = new Parent();
            Assert.AreEqual("parent", parent.Name);

            Child child = new Child();
            Assert.AreEqual("child", child.Name);
        }
 public NewParentCreatedEvent(Parent parent)
 {
     if (parent == null)
     {
         throw new ArgumentNullException("parent");
     }
     this.Parent = parent;
 }
	public static int Main (string[] args) {
		Parent p;
		Parent f = new Parent();
		Bar b = new Bar();
		p = args == null? (Parent) f : (Parent) b;

		return 1;
	}
 public void Parents()
 {
     var p1 = new Parent { new Child(1), new Child(2) };
     var p2 = new Parent { new Child(1), new Child(2) };
     var comparison = DeepEqualsNode.CreateFor(p1, p2);
     var dump = Dump(comparison);
     Console.Write(dump);
 }
	public static int Main (string[] args) {
		Parent p;
		Foo f = new Foo();
		Parent b = new Parent();
		p = args == null? (Parent) f : (Parent) b;

		return 1;
	}
Ejemplo n.º 21
0
 public Parent Create(Parent itemToCreate)
 {
     itemToCreate.Disable = false;
     _context.Users.Attach(itemToCreate.MyUser);
     var parent = _context.Parents.Add(itemToCreate);
     _context.SaveChanges();
     return parent;
 }
Ejemplo n.º 22
0
 public override void Poke(Parent parent)
 {
     base.Poke (parent);
     Debug.Log (tree.eventManager.gameObject);
     Debug.Log ("says");
     Debug.Log (message);
     parent.ReceiveStatus(Status.Success);
 }
        public void SetUp()
        {
            parent = new Parent("Mike Hadlow", "*****@*****.**", "pwd");
            child = parent.CreateChild("Leo", "leohadlow", "xxx");

            somebodyElse = new Parent("John Robinson", "*****@*****.**", "pwd");
            somebodyElsesChild = somebodyElse.CreateChild("Jim", "jimrobinson", "yyy");
        }
Ejemplo n.º 24
0
 public void ShouldGetProperty()
 {
     var instance = new Parent { Child = { Text = "foo" } };
     ReflectionUtil.GetProperty(instance, "Child").ShouldBe(Child.Instance);
     ReflectionUtil.GetProperty<Child>(instance, "Child").ShouldBe(Child.Instance);
     ReflectionUtil.GetProperty(instance, new[] { "Child", "Text", "Length" }).ShouldBe(3);
     ReflectionUtil.GetProperty<int>(instance, new[] { "Child", "Text", "Length" }).ShouldBe(3);
 }
Ejemplo n.º 25
0
 public ParentViewModel(Parent child)
 {
     PhoneNumber = child.PhoneNumber;
     FullName = child.FullName;
     Id = child.Id;
     Address = child.Address;
     WorkPlace = child.WorkPlace;
     Relatives = child.Relatives;
 }
 public void ChainingIfNullCreate()
 {
     var parent = new Parent();
     var grandChild = parent.IfNullCreate(x => x.Child, () => new Child()).IfNullCreate(y => y.GrandChild, () => new GrandChild());
     Assert.IsNotNull(grandChild);
     Assert.IsNotNull(parent.Child);
     Assert.IsNotNull(parent.Child.GrandChild);
     Assert.AreSame(grandChild, parent.Child.GrandChild);
 }
 public void ChainingWithDefaultConstructorVersion()
 {
     var parent = new Parent();
     var grandChild = parent.IfNullCreate(x => x.Child).IfNullCreate(y => y.GrandChild);
     Assert.IsNotNull(grandChild);
     Assert.IsNotNull(parent.Child);
     Assert.IsNotNull(parent.Child.GrandChild);
     Assert.AreSame(grandChild, parent.Child.GrandChild);
 }
        public void Parent_should_raise_an_event_when_created()
        {
            var parent = new Parent("Dad", "*****@*****.**", "xxx");
            parent.Initialise(mediator.Object);

            mediator.Verify(m => m.Publish(It.Is((INotification ev) =>
                ev is Domain.Events.NewParentCreatedEvent && ((Domain.Events.NewParentCreatedEvent) ev).Parent == parent)
                ));
        }
 public void NoTransactionDoesNotCommitParent()
 {
     Parent p = new Parent();
     p.Name = "Joe";
     session.Save(p);
     session.Clear();
     Parent p2 = session.Get<Parent>(p.Id);
     Assert.IsNull(p2);
 }
        public void SetUp()
        {
            mediator = new Mock<IMediator>();

            parent = new Parent("Dad", "*****@*****.**", "xxx");
            child = parent.CreateChild("Leo", "leohadlow", "yyy");
            parent.MakePaymentTo(child, 10.00M);

            somebodyElsesParent = new Parent("Not Dad", "*****@*****.**", "zzz");
        }
Ejemplo n.º 31
0
        public override void OnTick(EventArgs args)
        {
            if (!Menu.Item("use" + Name).GetValue <bool>() || !IsReady())
            {
                return;
            }

            foreach (var tar in Activator.Heroes)
            {
                if (!tar.Player.IsValidTarget(1500))
                {
                    continue;
                }

                if (tar.Player.HasBuff("kindredrnodeathbuff") || tar.Player.IsZombie ||
                    tar.Player.HasBuff("summonerdot"))
                {
                    continue;
                }

                if (!Parent.Item(Parent.Name + "useon" + tar.Player.NetworkId).GetValue <bool>())
                {
                    continue;
                }

                // ignite damagerino
                var ignotedmg = (float)Player.GetSummonerSpellDamage(tar.Player, Damage.SummonerSpell.Ignite);

                // killsteal ignite
                if (Menu.Item("mode" + Name).GetValue <StringList>().SelectedIndex == 0)
                {
                    if (tar.Player.Health <= ignotedmg)
                    {
                        if (tar.Player.Distance(Player.ServerPosition) <= 600)
                        {
                            UseSpellOn(tar.Player);
                        }
                    }
                }

                // combo ignite
                if (Menu.Item("mode" + Name).GetValue <StringList>().SelectedIndex == 1)
                {
                    var totaldmg = 0d;

                    switch (Player.ChampionName)
                    {
                    case "Akali":
                        totaldmg += R.GetDamage(tar.Player) * R.Instance.Ammo;
                        break;

                    case "Ahri":
                        if (!tar.Player.HasBuffOfType(BuffType.Charm) &&
                            Menu.Item("ii" + Player.ChampionName).GetValue <bool>() &&
                            E.IsReady())
                        {
                            continue;
                        }

                        totaldmg += R.IsReady() ? R.GetDamage(tar.Player) * 2 : 0;
                        break;

                    case "Cassiopeia":
                        if (!tar.Player.HasBuffOfType(BuffType.Poison) &&
                            Menu.Item("ii" + Player.ChampionName).GetValue <bool>() &&
                            (Q.IsReady() || W.IsReady()))
                        {
                            continue;
                        }

                        var dmg = Math.Min(6, Player.Mana / E.ManaCost) * E.GetDamage(tar.Player);
                        totaldmg += tar.Player.HasBuffOfType(BuffType.Poison) ? dmg * 2 : dmg;
                        break;

                    case "Diana":
                        if (!tar.Player.HasBuff("dianamoonlight") &&
                            Menu.Item("ii" + Player.ChampionName).GetValue <bool>() &&
                            Q.IsReady())
                        {
                            continue;
                        }

                        totaldmg += tar.Player.HasBuff("dianamoonlight")
                                ? R.GetDamage(tar.Player) * 2 : 0;
                        break;

                    case "Evelynn":
                    case "Orianna":
                    case "Lissandra":
                    case "Karthus":
                        totaldmg += Math.Min(6, Player.Mana / Q.ManaCost) * Q.GetDamage(tar.Player);
                        break;

                    case "Vayne":
                        totaldmg += Orbwalking.InAutoAttackRange(tar.Player)
                                ? Math.Min(6, Player.Mana / Q.ManaCost) * Q.GetDamage(tar.Player)
                                : 0;
                        break;
                    }

                    // aa dmg
                    totaldmg += Orbwalking.InAutoAttackRange(tar.Player)
                        ? Player.GetAutoAttackDamage(tar.Player, true) * 3
                        : 0;

                    // combo damge
                    totaldmg +=
                        Gamedata.DamageLib.Sum(
                            entry =>
                            Player.GetSpell(entry.Value).IsReady(2)
                                    ? entry.Key(Player, tar.Player, Player.GetSpell(entry.Value).Level - 1)
                                    : 0);

                    var finaldmg = totaldmg * Menu.Item("idmgcheck", true).GetValue <Slider>().Value / 100;

                    if (Menu.Item("idraw").GetValue <bool>())
                    {
                        var pdmg    = finaldmg > tar.Player.Health ? 100 : finaldmg * 100 / tar.Player.Health;
                        var drawdmg = Math.Round(pdmg);
                        var pos     = Drawing.WorldToScreen(tar.Player.Position);

                        Drawing.DrawText(pos[0], pos[1], System.Drawing.Color.Yellow, drawdmg + " %");
                    }

                    if (finaldmg + ignotedmg >= tar.Player.Health)
                    {
                        var nt = ObjectManager.Get <Obj_AI_Turret>().FirstOrDefault(
                            x => !x.IsDead && x.IsValid && x.Team == tar.Player.Team && tar.Player.Distance(x.Position) <= 1250);

                        if (nt != null && Menu.Item("itu").GetValue <bool>() && Player.Level <= Menu.Item("igtu").GetValue <Slider>().Value)
                        {
                            if (Player.CountAlliesInRange(750) == 0 && (totaldmg + ignotedmg / 1.85) < tar.Player.Health)
                            {
                                continue;
                            }
                        }

                        if (Orbwalking.InAutoAttackRange(tar.Player) && tar.Player.CountAlliesInRange(450) > 1)
                        {
                            if (totaldmg + ignotedmg / 2.5 >= tar.Player.Health)
                            {
                                continue;
                            }

                            if (nt != null && tar.Player.Distance(nt) <= 600)
                            {
                                continue;
                            }
                        }

                        if (tar.Player.Level <= 4 &&
                            tar.Player.InventoryItems.Any(item => item.Id == (ItemId)2003 || item.Id == (ItemId)2010))
                        {
                            continue;
                        }

                        if (tar.Player.Distance(Player.ServerPosition) <= 600)
                        {
                            UseSpellOn(tar.Player, true);
                        }
                    }
                }
            }
        }
        private bool EditParentDatabase()
        {
            bool   succes = true;
            Parent parentTemp;

            //Get parents from database

            using (DatabaseContext db = new DatabaseContext())
            {
                parentTemp = db.Parents.Select(x => x).Where(x => x.ParentID == SelectedStudent.ParentID).SingleOrDefault();
            }
            //If selected user exists, get information from form
            if (parentTemp != null)
            {
                if (InputInformationValidator.ValidateAddParentInput(windowAddStudent, ref errorMessage))
                {
                    parentTemp.FirstName  = windowAddStudent.AddParentFirstName.Text;
                    parentTemp.LastName   = windowAddStudent.AddParentLastName.Text;
                    parentTemp.Email      = windowAddStudent.AddParentEmail.Text;
                    parentTemp.Gender     = windowAddStudent.AddParentGender.SelectedItem.ToString();
                    parentTemp.Address    = windowAddStudent.AddParentStreet.Text;
                    parentTemp.Postalcode = windowAddStudent.AddParentPostalcode.Text;
                    parentTemp.Residence  = windowAddStudent.AddParentResidence.Text;

                    using (DatabaseContext db = new DatabaseContext())
                    {
                        // Mark entity as modified
                        db.Entry(parentTemp).State = System.Data.Entity.EntityState.Modified;

                        //Sla wijzigen op
                        db.SaveChanges();
                        windowOwner.UpdateDataGridPanelWithStudent();
                    }
                }
                else
                {
                    MessageBox.Show(errorMessage);
                    errorMessage = null;
                    succes       = false;
                }
            }
            else
            {
                if (!InputInformationValidator.ValidateAddParentInputReturnTrueWhenFieldsAreEmpty(windowAddStudent))
                {
                    if (InputInformationValidator.ValidateAddParentInput(windowAddStudent, ref errorMessage))
                    {
                        Parent parent = new Parent()
                        {
                            FirstName  = windowAddStudent.AddParentFirstName.Text,
                            LastName   = windowAddStudent.AddParentLastName.Text,
                            Email      = windowAddStudent.AddParentEmail.Text,
                            Gender     = windowAddStudent.AddParentGender.SelectedItem.ToString(),
                            Address    = windowAddStudent.AddParentStreet.Text,
                            Postalcode = windowAddStudent.AddParentPostalcode.Text,
                            Residence  = windowAddStudent.AddParentResidence.Text
                        };
                        using (DatabaseContext db = new DatabaseContext())
                        {
                            db.Parents.Add(parent);
                            db.SaveChanges();
                            int tempParentIDforUser = db.Parents.Max(x => x.ParentID);
                            var queryUser           = db.Users.Select(x => x).Where(x => x.UserID == SelectedStudent.UserID).FirstOrDefault();
                            queryUser.ParentID = tempParentIDforUser;

                            // Mark entity as modified
                            db.Entry(queryUser).State = System.Data.Entity.EntityState.Modified;

                            //Sla wijzigen op
                            db.SaveChanges();
                            windowOwner.UpdateDataGridPanelWithStudent();
                            MessageBox.Show("Ouder informatie is opgeslagen.");
                        }
                    }
                    else
                    {
                        succes = false;
                        MessageBox.Show(errorMessage);
                        errorMessage = null;
                    }
                }
            }
            return(succes);
        }
Ejemplo n.º 33
0
        public void Update(GameTime gameTime)
        {
            var body   = Parent.GetComponent <BodyComponent>();
            var sprite = Parent.GetComponent <SpriterComponent>();

            World.Camera.MoveTo(body.Position, 0.3f);
            World.Game.Hud.Observed = Parent;

            Vector2 movement  = Vector2.Zero;
            var     character = Parent.GetComponent <CharacterComponent>();
            var     inventory = Parent.GetComponent <InventoryComponent>();

            character.IsWalking = false;
            if (character.IsJumping && body.Grounded)
            {
                character.IsJumping = false;
            }

            if (World.Game.InputEnabled)
            {
                // Crouch
                if (World.Game.Input.GetInput(Inputs.Down, InputState.Pressed))
                {
                    if (!character.IsCrouching && !character.QueueContains <CrouchAction>())
                    {
                        character.AddToQueue(new CrouchAction());
                    }
                }
                else if (World.Game.Input.GetInput(Inputs.Down, InputState.Released))
                {
                    if (character.IsCrouching && !character.QueueContains <StandUpAction>())
                    {
                        character.AddToQueue(new StandUpAction());
                    }
                }

                if (!character.IsCrouching && character.QueueEmpty)
                {
                    if (World.Game.Input.GetInput(Inputs.Right, InputState.Down))
                    {
                        movement.X += character != null ? character.Speed : 120;
                    }

                    if (World.Game.Input.GetInput(Inputs.Left, InputState.Down))
                    {
                        movement.X -= character != null ? character.Speed : 120;
                    }

                    // Jump
                    if (World.Game.Input.GetInput(Inputs.Up, InputState.Pressed) && !character.IsJumping)
                    {
                        sprite.PlayAnim("jump_start", false, 0);
                        jump.Play();
                        movement.Y          = -100;
                        character.IsJumping = true;
                    }
                    else if (character.IsJumping)
                    {
                        if (body.Grounded)
                        {
                            character.IsJumping = false;
                        }
                    }

                    if (body.Grounded)
                    {
                        if (Math.Abs(movement.X) > Helper.EPSILON)
                        {
                            character.IsWalking = true;
                            sprite.PlayAnim("walk", false, 200);
                            sprite.Effect = movement.X > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
                        }
                        else
                        {
                            if ((sprite.Sprite.CurrentAnimation?.Name != "use" && sprite.Sprite.NextAnimation?.Name != "use") || sprite.Sprite.Progress >= 1f)
                            {
                                sprite.PlayAnim("idle", false, 200);
                            }
                        }
                    }
                    else
                    {
                        if (body.LinearVelocity.Y > 4)
                        {
                            sprite.PlayAnim("fall_start", false, 0);
                        }
                    }

                    body.Move(movement);
                }

                // --- REGION: State independent ---

                // Open inventory screen
                if (World.Game.Input.GetInput(Inputs.Inventory, InputState.Pressed))
                {
                    var g = World.Game.GuiManager.GetGuiOfType <Gui.InventoryScreen>();
                    if (g == null)
                    {
                        World.Game.GuiManager.Add(new Gui.InventoryScreen(Parent));
                    }
                    else
                    {
                        g.Closing = true;
                    }
                }

                character.Target = World.Camera.ToWorldSpace(World.Game.Input.GetPointerInput(0).Position) - body.Position;

                if (World.Game.Input.GetInput(Inputs.A, InputState.Down) &&
                    !World.Game.GuiManager.PointerInGui(World.Game.Input.GetPointerInput(0)) && inventory != null)
                {
                    inventory.Use(0);
                }

                // Swap weapons
                if (World.Game.Input.GetInput(Inputs.Swap, InputState.Pressed) && inventory != null)
                {
                    if (inventory.UseItems.Length >= 2)
                    {
                        var i = inventory.UseItems[0];
                        inventory.UseItems[0] = inventory.UseItems[1];
                        inventory.UseItems[1] = i;
                    }
                }

                // Use entity
                if (World.Game.Input.GetInput(Inputs.Use, InputState.Pressed))
                {
                    World.EntitiesAt(body.BoundingBox, (ent) =>
                    {
                        if (ent.Interact(Parent))
                        {
                            sprite.PlayAnim("use", true);
                            return(false);
                        }
                        return(true);
                    });
                }
            }

            // Final positioning things regardles of state and input
            light.Position = body.Position;
        }
Ejemplo n.º 34
0
 select(Parent: disk, Child: nodes[child])).Memoize()
Ejemplo n.º 35
0
 protected override void LLWrite(ICodeWriter writer, object o)
 {
     Parent.Write(writer, o);
     writer.Write('.', false);
     Child.Write(writer, o);
 }
Ejemplo n.º 36
0
 public override int GetHashCode() =>
 31 *ActorName.GetHashCode() + MailboxName.GetHashCode() + GetHashCode(Parameters) +
 Parent.GetHashCode() + Type.GetHashCode();
Ejemplo n.º 37
0
 public void Shot()
 {
     Parent.AddChild(new Bullet(contentManager, this.tankyBody.Position, new Vector2(0.2f, 0)));
 }
Ejemplo n.º 38
0
 public void GoToFirstPage()
 {
     Parent.RefreshMessages(SelectedEndpoint, 1, SearchQuery);
 }
Ejemplo n.º 39
0
        public override async Task Rebuild()
        {
            // check if we have initialized the Axis
            if (Axis.Origin.X == double.NegativeInfinity)
            {
                // make it something reasonable (just to the left of the aabb of the object)
                Axis.Origin = this.GetAxisAlignedBoundingBox().Center - new Vector3(-30, 0, 0);
            }

            var rebuildLock = this.RebuildLock();

            SourceContainer.Visible = true;

            await ApplicationController.Instance.Tasks.Execute(
                "Radial Array".Localize(),
                null,
                (reporter, cancellationToken) =>
            {
                this.DebugDepth("Rebuild");
                var aabb = this.GetAxisAlignedBoundingBox();

                // make sure our length is in the right axis
                for (int i = 0; i < 3; i++)
                {
                    if (Axis.Normal[i] != 0 && Axis.Origin[i] == 0)
                    {
                        var newOrigin = Vector3.Zero;
                        newOrigin[i]  = Math.Max(aabb.Center[0] - Axis.Origin[0],
                                                 Math.Max(aabb.Center[1] - Axis.Origin[1],
                                                          aabb.Center[2] - Axis.Origin[2]));
                    }
                }

                var sourceContainer = SourceContainer;
                this.Children.Modify(list =>
                {
                    list.Clear();
                    // add back in the sourceContainer
                    list.Add(sourceContainer);
                    // get the source item
                    var sourceItem = sourceContainer.Children.First();

                    var offset = Vector3.Zero;
                    for (int i = 0; i < Math.Max(Count, 1); i++)
                    {
                        var next = sourceItem.Clone();

                        var normal       = Axis.Normal.GetNormal();
                        var angleRadians = MathHelper.DegreesToRadians(Angle) / Count *i;
                        next.Rotate(Axis.Origin, normal, angleRadians);

                        if (!RotatePart)
                        {
                            var nextAabb = next.GetAxisAlignedBoundingBox();
                            next.Rotate(nextAabb.Center, normal, -angleRadians);
                        }

                        list.Add(next);
                    }
                });
                SourceContainer.Visible = false;
                rebuildLock.Dispose();
                Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children));
                return(Task.CompletedTask);
            });
        }
Ejemplo n.º 40
0
 public void CancelSearch()
 {
     SearchQuery      = null;
     SearchInProgress = false;
     Parent.RefreshMessages(SelectedEndpoint, 1, SearchQuery);
 }
Ejemplo n.º 41
0
 public void RefreshResult()
 {
     Parent.RefreshMessages(SelectedEndpoint, CurrentPage, SearchQuery);
 }
Ejemplo n.º 42
0
        private void RequestQueryString()
        {
            HiddenField hdnfield = (HiddenField)Parent.FindControl("hdn_ServerNum");

            ServerNum = Convert.ToInt32(hdnfield.Value);
        }
 private void Save()
 {
     //TODO:Validate User And Password
     Parent.ChangePassword(Password);
     _Form.DialogResult = true;
 }
Ejemplo n.º 44
0
 public override void Refresh()
 {
     base.Refresh();
     Parent.Refresh();
 }
            private void AnimateWindow(bool show)
            {
                if (!FlagAnimate && Visible != show)
                {
                    Visible = show;
                    return;
                }

                Parent.SuspendLayout();

                Rectangle rectSource = GetRectangle(!show);
                Rectangle rectTarget = GetRectangle(show);
                int       dxLoc, dyLoc;
                int       dWidth, dHeight;

                dxLoc = dyLoc = dWidth = dHeight = 0;
                if (DockState == DockState.DockTopAutoHide)
                {
                    dHeight = show ? 1 : -1;
                }
                else if (DockState == DockState.DockLeftAutoHide)
                {
                    dWidth = show ? 1 : -1;
                }
                else if (DockState == DockState.DockRightAutoHide)
                {
                    dxLoc  = show ? -1 : 1;
                    dWidth = show ? 1 : -1;
                }
                else if (DockState == DockState.DockBottomAutoHide)
                {
                    dyLoc   = (show ? -1 : 1);
                    dHeight = (show ? 1 : -1);
                }

                if (show)
                {
                    Bounds = DockPanel.GetAutoHideWindowBounds(new Rectangle(-rectTarget.Width, -rectTarget.Height, rectTarget.Width, rectTarget.Height));
                    if (Visible == false)
                    {
                        Visible = true;
                    }
                    PerformLayout();
                }

                SuspendLayout();

                LayoutAnimateWindow(rectSource);
                if (Visible == false)
                {
                    Visible = true;
                }

                int speedFactor = 1;
                int totalPixels = (rectSource.Width != rectTarget.Width) ?
                                  Math.Abs(rectSource.Width - rectTarget.Width) :
                                  Math.Abs(rectSource.Height - rectTarget.Height);
                int      remainPixels = totalPixels;
                DateTime startingTime = DateTime.Now;

                while (rectSource != rectTarget)
                {
                    DateTime startPerMove = DateTime.Now;

                    rectSource.X      += dxLoc * speedFactor;
                    rectSource.Y      += dyLoc * speedFactor;
                    rectSource.Width  += dWidth * speedFactor;
                    rectSource.Height += dHeight * speedFactor;
                    if (Math.Sign(rectTarget.X - rectSource.X) != Math.Sign(dxLoc))
                    {
                        rectSource.X = rectTarget.X;
                    }
                    if (Math.Sign(rectTarget.Y - rectSource.Y) != Math.Sign(dyLoc))
                    {
                        rectSource.Y = rectTarget.Y;
                    }
                    if (Math.Sign(rectTarget.Width - rectSource.Width) != Math.Sign(dWidth))
                    {
                        rectSource.Width = rectTarget.Width;
                    }
                    if (Math.Sign(rectTarget.Height - rectSource.Height) != Math.Sign(dHeight))
                    {
                        rectSource.Height = rectTarget.Height;
                    }

                    LayoutAnimateWindow(rectSource);
                    if (Parent != null)
                    {
                        Parent.Update();
                    }

                    remainPixels -= speedFactor;

                    while (true)
                    {
                        TimeSpan time           = new TimeSpan(0, 0, 0, 0, ANIMATE_TIME);
                        TimeSpan elapsedPerMove = DateTime.Now - startPerMove;
                        TimeSpan elapsedTime    = DateTime.Now - startingTime;
                        if (((int)((time - elapsedTime).TotalMilliseconds)) <= 0)
                        {
                            speedFactor = remainPixels;
                            break;
                        }
                        else
                        {
                            speedFactor = remainPixels * (int)elapsedPerMove.TotalMilliseconds / (int)((time - elapsedTime).TotalMilliseconds);
                        }
                        if (speedFactor >= 1)
                        {
                            break;
                        }
                    }
                }
                ResumeLayout();
                Parent.ResumeLayout();
            }
Ejemplo n.º 46
0
        /// <summary>
        /// Creates a copy of this SearchNode.
        /// </summary>
        /// <returns>A copy of this SearchNode.</returns>
        public SearchNode <S, A> Copy()
        {
            var newNode = IsRoot() ? new SearchNode <S, A>(State, Payload) : new SearchNode <S, A>(Parent.Copy(), State, Payload);

            newNode.Children = new List <SearchNode <S, A> >(Children);
            return(newNode);
        }
Ejemplo n.º 47
0
 protected virtual Task <Message> SendMarkupIfNoChildren(ISession session) => Parent.SendMessage(session);
        public void SerializeReadOnlyProperty()
        {
            Child c = new Child
            {
                PropertyName = "value?"
            };
            IList <string> l = new List <string>
            {
                "value!"
            };
            Parent p = new Parent
            {
                Child1 = c,
                Child2 = c,
                List1  = l,
                List2  = l
            };

            string json = JsonConvert.SerializeObject(p, new JsonSerializerSettings
            {
                Formatting = Formatting.Indented,
                PreserveReferencesHandling = PreserveReferencesHandling.All
            });

            StringAssert.AreEqual(@"{
  ""$id"": ""1"",
  ""ReadOnlyChild"": {
    ""PropertyName"": ""value?""
  },
  ""Child1"": {
    ""$id"": ""2"",
    ""PropertyName"": ""value?""
  },
  ""Child2"": {
    ""$ref"": ""2""
  },
  ""ReadOnlyList"": [
    ""value!""
  ],
  ""List1"": {
    ""$id"": ""3"",
    ""$values"": [
      ""value!""
    ]
  },
  ""List2"": {
    ""$ref"": ""3""
  }
}", json);

            Parent newP = JsonConvert.DeserializeObject <Parent>(json, new JsonSerializerSettings
            {
                Formatting = Formatting.Indented,
                PreserveReferencesHandling = PreserveReferencesHandling.All
            });

            Assert.AreEqual("value?", newP.Child1.PropertyName);
            Assert.AreEqual(newP.Child1, newP.Child2);
            Assert.AreEqual(newP.Child1, newP.ReadOnlyChild);

            Assert.AreEqual("value!", newP.List1[0]);
            Assert.AreEqual(newP.List1, newP.List2);
            Assert.AreEqual(newP.List1, newP.ReadOnlyList);
        }
Ejemplo n.º 49
0
 public override string Compile()
 {
     return(String.Format("{{ htmlgump {0} {1} {2} {3} {4} {5} {6} }}", m_X, m_Y, m_Width, m_Height, m_Text == null ? m_TextID : Parent.Intern(m_Text), m_Background ? 1 : 0, m_Scrollbar ? 1 : 0));
 }
Ejemplo n.º 50
0
 public void Search()
 {
     SearchInProgress = true;
     AddRecentSearchEntry(SearchQuery);
     Parent.RefreshMessages(SelectedEndpoint, 1, SearchQuery);
 }
Ejemplo n.º 51
0
        internal void Serialize(XmlSerializer serializer, string name, ParagraphFormat refFormat)
        {
            serializer.WriteStartElement(name);

            //int pos = serializer.BeginContent(name);

//            if (!IsNull("Font") && Parent.GetType() != typeof(Style))
            //Font.Serialize(serializer);

            // If a refFormat is specified, it is important to compare the fields and not the properties.
            // Only the fields holds the internal information whether a value is NULL. In contrast to the
            // Efw.Application framework the nullable values and all the meta stuff is kept internal to
            // give the user the illusion of simplicity.

            if (!_alignment.IsNull && (refFormat == null || (_alignment != refFormat._alignment)))
            {
                serializer.WriteSimpleAttribute("Alignment", Alignment);
            }

            if (!_leftIndent.IsNull && (refFormat == null || (_leftIndent != refFormat._leftIndent)))
            {
                serializer.WriteSimpleAttribute("LeftIndent", LeftIndent);
            }

            if (!_firstLineIndent.IsNull && (refFormat == null || _firstLineIndent != refFormat._firstLineIndent))
            {
                serializer.WriteSimpleAttribute("FirstLineIndent", FirstLineIndent);
            }

            if (!_rightIndent.IsNull && (refFormat == null || _rightIndent != refFormat._rightIndent))
            {
                serializer.WriteSimpleAttribute("RightIndent", RightIndent);
            }

            if (!_spaceBefore.IsNull && (refFormat == null || _spaceBefore != refFormat._spaceBefore))
            {
                serializer.WriteSimpleAttribute("SpaceBefore", SpaceBefore);
            }

            if (!_spaceAfter.IsNull && (refFormat == null || _spaceAfter != refFormat._spaceAfter))
            {
                serializer.WriteSimpleAttribute("SpaceAfter", SpaceAfter);
            }

            if (!_lineSpacingRule.IsNull && (refFormat == null || _lineSpacingRule != refFormat._lineSpacingRule))
            {
                serializer.WriteSimpleAttribute("LineSpacingRule", LineSpacingRule);
            }

            if (!_lineSpacing.IsNull && (refFormat == null || _lineSpacing != refFormat._lineSpacing))
            {
                serializer.WriteSimpleAttribute("LineSpacing", LineSpacing);
            }

            if (!_keepTogether.IsNull && (refFormat == null || _keepTogether != refFormat._keepTogether))
            {
                serializer.WriteSimpleAttribute("KeepTogether", KeepTogether);
            }

            if (!_keepWithNext.IsNull && (refFormat == null || _keepWithNext != refFormat._keepWithNext))
            {
                serializer.WriteSimpleAttribute("KeepWithNext", KeepWithNext);
            }

            if (!_widowControl.IsNull && (refFormat == null || _widowControl != refFormat._widowControl))
            {
                serializer.WriteSimpleAttribute("WidowControl", WidowControl);
            }

            if (!_pageBreakBefore.IsNull && (refFormat == null || _pageBreakBefore != refFormat._pageBreakBefore))
            {
                serializer.WriteSimpleAttribute("PageBreakBefore", PageBreakBefore);
            }

            if (!_outlineLevel.IsNull && (refFormat == null || _outlineLevel != refFormat._outlineLevel))
            {
                serializer.WriteSimpleAttribute("OutlineLevel", OutlineLevel);
            }

            if (!IsNull("Font") && Parent.GetType() != typeof(Style))
            {
                Font.Serialize(serializer);
            }

            if (!IsNull("ListInfo"))
            {
                ListInfo.Serialize(serializer);
            }

            if (!IsNull("TabStops"))
            {
                _tabStops.Serialize(serializer);
            }

            if (!IsNull("Borders"))
            {
                if (refFormat != null)
                {
                    _borders.Serialize(serializer, refFormat.Borders);
                }
                else
                {
                    _borders.Serialize(serializer, null);
                }
            }

            if (!IsNull("Shading"))
            {
                _shading.Serialize(serializer);
            }

            //serializer.EndContent(pos);
            serializer.WriteEndElement(); // paragraphFormat
        }
Ejemplo n.º 52
0
 internal TreeViewItemViewModel GetRoot()
 {
     return(Parent == null ? this : Parent.GetRoot());
 }
Ejemplo n.º 53
0
 /// <summary>
 /// Gets the ancestor component of specified type or self.
 /// </summary>
 /// <typeparam name="TComponentToFind">The type of the component to find.</typeparam>
 /// <returns>The component or <see langword="null"/> if not found.</returns>
 public TComponentToFind GetAncestorOrSelf <TComponentToFind>()
     where TComponentToFind : UIComponent <TOwner>
 {
     return((this as TComponentToFind) ?? Parent?.GetAncestorOrSelf <TComponentToFind>());
 }
Ejemplo n.º 54
0
        public override void Login(string Username, string Password, string otp)
        {
            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                //RequireCaptchaEventArgs Captchaval = new RequireCaptchaEventArgs { PublicKey = CaptchaKey, Domain=this.URL };
                //RequireCaptcha(Captchaval);
                GQLClient = new GraphQL.Client.GraphQLClient(URL);

                /*GraphQLRequest LoginReq = new GraphQLRequest
                 * {
                 *  Query = "mutation{loginUser(captcha:\""+Captchaval.ResponseValue+ "\" name:\"" + Username + "\", password:\"" + Password + "\"" + (string.IsNullOrWhiteSpace(otp) ? "" : ",tfaToken:\"" + otp + "\"") + ") {activeServerSeed { seedHash seed nonce} activeClientSeed {seed} id statistic {bets wins losses amount profit currency} balances{available{currency amount}} }}"
                 * };
                 *
                 * GQLClient
                 * GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                 * if (Resp.Errors != null)
                 * {
                 *  if (Resp.Errors.Length > 0)
                 *  {
                 *      Parent.DumpLog(Resp.Errors[0].Message, -1);
                 *      Parent.updateStatus(Resp.Errors[0].Message);
                 *      finishedlogin(false);
                 *      return;
                 *  }
                 * }
                 * pdUser user = Resp.GetDataFieldAs<pdUser>("loginUser");*/
                GQLClient.DefaultRequestHeaders.Add("x-access-token", Password);

                /*
                 * var subscriptionResult = GQLClient.SendSubscribeAsync(@"subscription { chatMessages(chatId: "14939265 - 52a4 - 404e-8a0c - 6e3e10d915b4") { id chat { id name isPublic } createdAt user { id name roles { name } } data { ... on ChatMessageDataBot { message } ... on ChatMessageDataText { message } ... on ChatMessageDataTip { tip { id amount currency sender: sendBy { id name } receiver: user { id name } } } } } } ").Result;
                 * subscriptionResult.OnReceive += (res) => { Console.WriteLine(res.Data.messageAdded.content); };
                 */


                GraphQLRequest LoginReq = new GraphQLRequest
                {
                    Query = "query DiceBotLogin{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}"
                };
                GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                pdUser          user = Resp.GetDataFieldAs <pdUser>("user");

                userid = user.id;
                if (string.IsNullOrWhiteSpace(userid))
                {
                    finishedlogin(false);
                }
                else
                {
                    foreach (Statistic x in user.statistic)
                    {
                        if (x.currency.ToLower() == Currency.ToLower() && x.game == StatGameName)
                        {
                            this.bets    = (int)x.bets;
                            this.wins    = (int)x.wins;
                            this.losses  = (int)x.losses;
                            this.profit  = (decimal)x.profit;
                            this.wagered = (decimal)x.betAmount;
                            break;
                        }
                    }
                    foreach (Balance x in user.balances)
                    {
                        if (x.available.currency.ToLower() == Currency.ToLower())
                        {
                            balance = (decimal)x.available.amount;
                            break;
                        }
                    }

                    finishedlogin(true);
                    ispd = true;
                    Thread t = new Thread(GetBalanceThread);
                    t.Start();
                    return;
                }
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                }
                finishedlogin(false);
            }
            catch (Exception e)
            {
                Parent.DumpLog(e.ToString(), -1);
                finishedlogin(false);
            }
        }
Ejemplo n.º 55
0
 public void GoToPreviousPage()
 {
     Parent.RefreshMessages(SelectedEndpoint, CurrentPage - 1, SearchQuery);
 }
Ejemplo n.º 56
0
 public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent.ReceivePositionalInputAt(screenSpacePos);
Ejemplo n.º 57
0
 public void GoToNextPage()
 {
     Parent.RefreshMessages(SelectedEndpoint, CurrentPage + 1, SearchQuery);
 }
Ejemplo n.º 58
0
 public void GoToLastPage()
 {
     Parent.RefreshMessages(SelectedEndpoint, PageCount, SearchQuery);
 }
Ejemplo n.º 59
0
        void placebetthread(object bet)
        {
            try
            {
                PlaceBetObj tmp5   = bet as PlaceBetObj;
                decimal     amount = tmp5.Amount;
                decimal     chance = tmp5.Chance;
                bool        High   = tmp5.High;

                decimal tmpchance = High ? maxRoll - chance : chance;
                var     Request   = new GraphQLRequest {
                    Query = @"mutation DiceBotDiceBet($amount: Float! 
  $target: Float!
  $condition: " + EnumName + @"!
  $currency: CurrencyEnum!
  $identifier: String!){ " + RolName + "(amount: $amount, target: $target,condition: $condition,currency: $currency, identifier: $identifier)" +
                            " { id nonce currency amount payout state { ... on " + GameName + " { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses betAmount profit currency}}}}"
                };
                Request.Variables = new
                {
                    amount     = amount,    //.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo),
                    target     = tmpchance, //.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo),
                    condition  = (High ? "above" : "below"),
                    currency   = Currency.ToLower(),
                    identifier = "0123456789abcdef",
                };
                GraphQLResponse betresult = GQLClient.PostAsync(Request).Result;

                if (betresult.Errors != null)
                {
                    if (betresult.Errors.Length > 0)
                    {
                        Parent.updateStatus(betresult.Errors[0].Message);
                    }
                }
                if (betresult.Data != null)
                {
                    RollDice tmp = betresult.GetDataFieldAs <RollDice>(RolName);


                    Lastbet = DateTime.Now;
                    try
                    {
                        lastupdate = DateTime.Now;
                        foreach (Statistic x in tmp.user.statistic)
                        {
                            if (x.currency.ToLower() == Currency.ToLower() && x.game == StatGameName)
                            {
                                this.bets    = (int)x.bets;
                                this.wins    = (int)x.wins;
                                this.losses  = (int)x.losses;
                                this.profit  = (decimal)x.profit;
                                this.wagered = (decimal)x.betAmount;
                                break;
                            }
                        }
                        foreach (Balance x in tmp.user.balances)
                        {
                            if (x.available.currency.ToLower() == Currency.ToLower())
                            {
                                balance = (decimal)x.available.amount;
                                break;
                            }
                        }
                        Bet tmpbet = tmp.ToBet(maxRoll);

                        if (getid)
                        {
                            var IdRequest = new GraphQLRequest {
                                Query = " query DiceBotGetBetId($betId: String!){bet(betId: $betId){iid}}"
                            };
                            string betid = tmpbet.Id;
                            IdRequest.Variables = new { betId = betid /*tmpbet.Id*/ };
                            GraphQLResponse betresult2 = GQLClient.PostAsync(IdRequest).Result;

                            if (betresult2.Data != null)
                            {
                                //RollDice tmp2 = betresult2.GetDataFieldAs<RollDice>(RolName);

                                //tmpbet.Id = tmp2.iid;
                                tmpbet.Id = betresult2.Data.bet.iid;
                                if (tmpbet.Id.Contains("house:"))
                                {
                                    tmpbet.Id = tmpbet.Id.Substring("house:".Length);
                                }
                            }
                        }

                        tmpbet.Guid = tmp5.Guid;
                        FinishedBet(tmpbet);
                        retrycount = 0;
                    }
                    catch (Exception e)
                    {
                        Parent.DumpLog(e.ToString(), -1);
                        Parent.updateStatus("Some kind of error happened. I don't really know graphql, so your guess as to what went wrong is as good as mine.");
                    }
                }
            }
            catch (AggregateException e)
            {
                if (retrycount++ < 3)
                {
                    Thread.Sleep(500);
                    placebetthread(new PlaceBetObj(High, amount, chance, (bet as PlaceBetObj).Guid));
                    return;
                }
                if (e.InnerException.Message.Contains("429") || e.InnerException.Message.Contains("502"))
                {
                    Thread.Sleep(500);
                    placebetthread(new PlaceBetObj(High, amount, chance, (bet as PlaceBetObj).Guid));
                }
            }
            catch (Exception e2)
            {
                Parent.updateStatus("Error occured while trying to bet, retrying in 30 seconds. Probably.");
                Parent.DumpLog(e2.ToString(), -1);
            }
        }
Ejemplo n.º 60
0
		Expression BuildExpressionInternal(Expression? expression, int level, bool enforceServerSide)
#endif
		{
			{
				var key = Tuple.Create(expression, level, ConvertFlags.Field);

				if (_expressionIndex.TryGetValue(key, out var info))
				{
					var idx  = Parent?.ConvertToParentIndex(info[0].Index, this) ?? info[0].Index;

					var expr = expression ?? Body;

					if (IsExpression(expr, level, RequestFor.Object).Result)
						return Builder.BuildExpression(this, expr, enforceServerSide);

					return Builder.BuildSql(expr.Type, idx);
				}
			}

			if (expression == null)
			{
				if (_rootExpression == null)
				{
					var expr = Builder.BuildExpression(this, Body, enforceServerSide);

					if (Builder.IsBlockDisable)
						return expr;

					_rootExpression = Builder.BuildVariable(expr);
				}

				return _rootExpression;
			}

			var levelExpression = expression.GetLevelExpression(Builder.MappingSchema, level);

			if (IsScalar)
			{
				if (Body.NodeType != ExpressionType.Parameter && level == 0)
					if (ReferenceEquals(levelExpression, expression))
						if (IsSubQuery() && IsExpression(null, 0, RequestFor.Expression).Result)
						{
							var info = ConvertToIndex(expression, level, ConvertFlags.Field).Single();
							var idx = Parent?.ConvertToParentIndex(info.Index, this) ?? info.Index;

							return Builder.BuildSql(expression.Type, idx);
						}

				return ProcessScalar(
					expression,
					level,
					(ctx, ex, l) => ctx.BuildExpression(ex, l, enforceServerSide),
					() => GetSequence(expression, level)!.BuildExpression(null, 0, enforceServerSide));
			}
			else
			{
				if (level == 0)
				{
					var sequence = GetSequence(expression, level)!;

					Builder.AssociationRoot = expression;

					return ReferenceEquals(levelExpression, expression) ?
						sequence.BuildExpression(null,       0,         enforceServerSide) :
						sequence.BuildExpression(expression, level + 1, enforceServerSide);
				}

				switch (levelExpression.NodeType)
				{
					case ExpressionType.MemberAccess :
						{
							var memberInfo = ((MemberExpression)levelExpression).Member;

							var memberExpression = GetMemberExpression(
								memberInfo,
								ReferenceEquals(levelExpression, expression),
								levelExpression.Type,
								expression);

							if (ReferenceEquals(levelExpression, expression))
							{
								if (IsSubQuery())
								{
									switch (memberExpression.NodeType)
									{
										case ExpressionType.New        :
										case ExpressionType.MemberInit :
											{
												var resultExpression = memberExpression.Transform(e =>
												{
													if (!ReferenceEquals(e, memberExpression))
													{
														switch (e.NodeType)
														{
															case ExpressionType.MemberAccess :
															case ExpressionType.Parameter :
																{
																	var sequence = GetSequence(e, 0)!;
																	return Builder.BuildExpression(sequence, e, enforceServerSide);
																}
															default:
																{
																	if (e is ContextRefExpression refExpression)
																	{
																		return Builder.BuildExpression(refExpression.BuildContext, e, enforceServerSide);
																	}

																	break;
																}
														}

														if (enforceServerSide)
															return Builder.BuildExpression(this, e, true);
													}

													return e;
												});

												return resultExpression;
											}
									}

									var me = memberExpression.NodeType == ExpressionType.Parameter ? null : memberExpression;

									if (!IsExpression(me, 0, RequestFor.Object).Result &&
										!IsExpression(me, 0, RequestFor.Field). Result)
									{
										var info = ConvertToIndex(expression, level, ConvertFlags.Field).Single();
										var idx  = Parent?.ConvertToParentIndex(info.Index, this) ?? info.Index;

										return Builder.BuildSql(expression.Type, idx);
									}
								}

								return Builder.BuildExpression(this, memberExpression, enforceServerSide, memberInfo.Name);
							}

							{
								var sequence = GetSequence(expression, level);

								switch (memberExpression.NodeType)
								{
									case ExpressionType.Parameter  :
										{
											var parameter = Lambda.Parameters[Sequence.Length == 0 ? 0 : Array.IndexOf(Sequence, sequence)];

											if (ReferenceEquals(memberExpression, parameter))
												return sequence!.BuildExpression(expression, level + 1, enforceServerSide);

											break;
										}

									case ExpressionType.New        :
									case ExpressionType.MemberInit :
										{
											var mmExpression = GetMemberExpression(memberExpression, expression, level + 1);
											return Builder.BuildExpression(this, mmExpression, enforceServerSide);
										}
									default:
										{
											if (memberExpression is ContextRefExpression refExpression)
											{
												return refExpression.BuildContext.BuildExpression(memberExpression, level + 1, enforceServerSide);
											}
											break;
										}
								}

								var expr = expression.Transform(ex => ReferenceEquals(ex, levelExpression) ? memberExpression : ex);

								if (sequence == null)
									return Builder.BuildExpression(this, expr, enforceServerSide);

								return sequence.BuildExpression(expr, 1, enforceServerSide);
							}
						}

					case ExpressionType.Parameter :
						break;
				}
			}

			throw new NotImplementedException();
		}