Esempio n. 1
0
 public FamilyExtensionsTests()
 {
     _us = new Family();  _dad = _us.Add();  _mom = _us.Add();  _brother = _us.Add();  _sister = _us.Add();  _cat = _us.Add();
     _expectedChildren = new List <Person> {
         _brother, _sister, _cat
     };
 }
Esempio n. 2
0
        public void WriteToJson()
        {
            var family = new Family();
            var me     = family.Add("me");

            family.Add("mom").Is.TheParentOf(me);
            family.Add("dad").Is.TheParentOf(me);
            DebugWrite(family);
        }
Esempio n. 3
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.");
        }
Esempio n. 4
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.");
        }
        /// <summary>
        /// Saves family member to database
        /// </summary>
        private async Task SaveFamilyMember()
        {
            try
            {
                _selected.Model.Familiar = _selected.Familiar.Model;
                if (_selected.Empleado != null && _selected.Model.Familiar != null)
                {
                    var result = await App.Repository.Family.UpsertAsync(_selected.Model);

                    if (!Family.Contains(_selected))
                    {
                        Family.Add(new FamiliarViewModel(result));
                    }
                }
            } catch (Exception ex)
            {
                var dialog = new ContentDialog()
                {
                    Title             = "No se pudo guardar.",
                    Content           = $"Ocurrió un error al guardar:\n{ex.Message}",
                    PrimaryButtonText = "OK"
                };
                await dialog.ShowAsync();
            }
        }
Esempio n. 6
0
 protected void AddButtonClickedHandler(object o, EventArgs args)
 {
     familylist.Add(new Person("Joe #" + (worldlist.Count + 1), "Somebody #" + (worldlist.Count + 1), 1, (worldlist.Count % 2) == 0));
     worldlist.Add(new Person("Joe #" + (worldlist.Count + 1), "Somebody #" + (worldlist.Count + 1), 1, (worldlist.Count % 2) == 0));
     personlist.Add(new Person("Joe #" + (worldlist.Count + 1), "Somebody #" + (worldlist.Count + 1), 1, (worldlist.Count % 2) == 0));
     subpersonlist.Add(new Person("Joe #" + (worldlist.Count + 1), "Somebody #" + (worldlist.Count + 1), 1, (worldlist.Count % 2) == 0));
     subsubpersonlist.Add(new Person("Joe #" + (worldlist.Count + 1), "Somebody #" + (worldlist.Count + 1), 1, (worldlist.Count % 2) == 0));
     strings[5] = strings[5] + "A";
 }
Esempio n. 7
0
    //<summary>
    /// This is sample code needed to create list that handles hierarchy in treeview in this demo
    //</summary>
    public void ActualListCode()
    {
        subsubpersonlist = new Family("subsubpersonlist");
        subpersonlist    = new Family("subpersonlist");
        personlist       = new Family("Adams family");
        worldlist        = new Family("World");
        familylist       = new Family("Munchcrunchkins");

        person  = new Person("Joe", "Somebody", 1, true);
        person2 = new Person("Tomy", "Knokers", 15, false);

        VirtualObject vo = new UniqueVirtualObject("PERSON", person);

        Console.WriteLine("Person Name=" + vo["thisperson"].Value);
        subpersonlist.Add(subsubpersonlist);
        personlist.Add(subpersonlist);
        personlist.Add(person);
        personlist.Add(person2);

        familylist.Add(worldlist);
        for (int i = 0; i < 10; i++)
        {
            familylist.Add(new Person("familyperson" + i, "familyperson" + i, 1, true));
        }
        worldlist.Add(personlist);
        for (int i = 0; i < 10; i++)
        {
            worldlist.Add(new Person("worldperson" + i, "worldperson" + i, 1, true));
        }
        for (int i = 0; i < 10; i++)
        {
            subpersonlist.Add(new Person("subperson" + i, "subperson" + i, 1, true));
        }
        for (int i = 0; i < 10; i++)
        {
            subsubpersonlist.Add(new Person("subsubperson" + i, "subsubperson" + i, 1, true));
        }

        strings = new ObserveableStringCollection();
        for (int i = 0; i < 10; i++)
        {
            strings.Add("String #" + i);
        }
    }
        /// <summary>
        /// Loads the family members of the selected employee Async.
        /// </summary>
        public async Task LoadDataAsync(MasterDetailsViewState viewState)
        {
            Family.Clear();
            var data = await App.Repository.Family.GetEmployeeFamilyAsync(App.SelectedEmployee.IdEmpleado);

            foreach (var item in data)
            {
                Family.Add(new FamiliarViewModel(item));
            }
            if (viewState == MasterDetailsViewState.Both)
            {
                Selected = Family.FirstOrDefault();
            }
        }
Esempio n. 9
0
        public void RefreshMembersList()
        {
            Family.Clear();
            Companions.Clear();
            List <Hero> list = new List <Hero>();

            foreach (Hero noble in _faction.Nobles)
            {
                HeroHelper.SetLastSeenLocation(noble, willUpdateImmediately: true);
                if (noble.IsAlive)
                {
                    if (noble == Hero.MainHero)
                    {
                        list.Insert(0, noble);
                    }
                    else
                    {
                        list.Add(noble);
                    }
                }
            }
            IEnumerable <Hero> enumerable = _faction.Companions.Where((Hero m) => m.IsPlayerCompanion);

            foreach (Hero item in list)
            {
                Family.Add(new WangLordItemVM(item, OnMemberSelection));
            }
            foreach (Hero item2 in enumerable)
            {
                Companions.Add(new WangLordItemVM(item2, OnMemberSelection));
            }
            GameTexts.SetVariable("COMPANION_COUNT", _faction.Companions.Count());
            GameTexts.SetVariable("COMPANION_LIMIT", _faction.CompanionLimit);
            CompanionsText = GameTexts.FindText("str_companions_group").ToString();
            OnMemberSelection(GetDefaultMember());
        }
Esempio n. 10
0
 private void InitializePeople()
 {
     john                   = kennedy.Add("John");
     joe                    = kennedy.Add("Joe");
     rosemary               = kennedy.Add("Rosemary");
     jackie                 = kennedy.Add("Jackie");
     jackiesSecondHusband   = kennedy.Add("JackiesSecondHusband");
     kathleen               = kennedy.Add("Kathleen");
     eunice                 = kennedy.Add("Eunice");
     pat                    = kennedy.Add("Pat");
     robert                 = kennedy.Add("Robert");
     jean                   = kennedy.Add("Jean");
     ted                    = kennedy.Add("Ted");
     miscarriage            = kennedy.Add("miscarriage");
     daughter1              = kennedy.Add("daughter1");
     daughter2              = kennedy.Add("daughter2");
     son1                   = kennedy.Add("son1");
     son2                   = kennedy.Add("son2");
     kathleensHusband       = kennedy.Add("KathleensHusband");
     kathleensSecondHusband = kennedy.Add("KathleensSecondHusband");
     ethyl                  = kennedy.Add("Ethyl");
     rdaughter1             = kennedy.Add("rdaughter1");
     rson1                  = kennedy.Add("rson1");
     rson2                  = kennedy.Add("rson2");
     rson3                  = kennedy.Add("rson3");
     rdaughter2             = kennedy.Add("rdaughter2");
     rson4                  = kennedy.Add("rson4");
     rdaugher3              = kennedy.Add("rdaugher3");
     rson5                  = kennedy.Add("rson5");
     rson6                  = kennedy.Add("rson6");
     rson7                  = kennedy.Add("rson7");
     rdaugher4              = kennedy.Add("rdaugher4");
     joseph                 = kennedy.Add("Joseph");
     rose                   = kennedy.Add("Rose");
     gloria                 = kennedy.Add("Gloria");
     patrick                = kennedy.Add("Patrick");
     patricksWife           = kennedy.Add("PatricksWife");
     pdaughter1             = kennedy.Add("pdaughter1");
     pdaughter2             = kennedy.Add("pdaughter2");
     fitz                   = kennedy.Add("Fitz");
     mary                   = kennedy.Add("Mary");
     toodles                = kennedy.Add("Toodles");
     fdaughter2             = kennedy.Add("fdaughter2");
     fson1                  = kennedy.Add("fson1");
     fson2                  = kennedy.Add("fson2");
     fdaughter3             = kennedy.Add("fdaughter3");
     fson3                  = kennedy.Add("fson3");
     people                 = new List <Person> {
         john, joe, rosemary, jackie, jackiesSecondHusband, kathleen, eunice, pat, robert, jean, ted, miscarriage, daughter1, daughter2,
         son1, son2, kathleensHusband, kathleensSecondHusband, ethyl, rdaughter1, rson1, rson2, rson3, rdaughter2, rson4, rdaugher3, rson5, rson6, rson7, rdaugher4,
         joseph, rose, gloria, patrick, patricksWife, pdaughter1, pdaughter2, fitz, mary, toodles, fdaughter2, fson1, fson2, fdaughter3, fson3
     };
 }