public void Test002()
        {
            MyObservableList <string> people = new MyObservableList <string>();

            MyObservableList <string> filteredPeople = people.Sublist(i => i.StartsWith("a", StringComparison.CurrentCultureIgnoreCase), SublistSortOption.SameAsParentList);

            AssertListsEqual(new string[0], filteredPeople);


            people.Add("Lei");
            people.Add("Andrew");
            people.Add("Matt");

            AssertListsEqual(new string[] { "Andrew" }, filteredPeople);


            people.Add("Thomas");
            people.Add("Steve");

            AssertListsEqual(new string[] { "Andrew" }, filteredPeople);


            people.Add("Adam");

            AssertListsEqual(new string[] { "Andrew", "Adam" }, filteredPeople);


            people.Add("Frank");
            people.Add("Jessica");

            AssertListsEqual(new string[] { "Andrew", "Adam" }, filteredPeople);
        }
Beispiel #2
0
            public GroupedDay(MyObservableList <ViewItemSchedule> allSchedules, DayOfWeek dayOfWeek)
            {
                DayOfWeek = dayOfWeek;

                Times = allSchedules.Sublist(i => i.DayOfWeek == DayOfWeek);
                Times.CollectionChanged += Schedules_CollectionChanged;

                ResetVisibility();
            }
Beispiel #3
0
            public GroupedDay(MyObservableList <ViewItemSchedule> allSchedules, DayOfWeek dayOfWeek)
            {
                DayOfWeek = dayOfWeek;

                var date = DateTools.Next(dayOfWeek, DateTime.Today);

                Times = allSchedules.Sublist(i => i.OccursOnDate(date));
                Times.CollectionChanged += Schedules_CollectionChanged;

                ResetVisibility();
            }
        private async void Initialize()
        {
            Accounts = new MyObservableList <AccountDataItem>(await AccountsManager.GetAllAccounts());

            // TODO: What if RememberUsername is edited? That's quite a minor case, not worth building something for, but it's potentially a flaw
            AccountsWithRememberUsername = Accounts.Sublist(i => i.RememberUsername && !i.IsDefaultOfflineAccount);

            AccountsManager.OnAccountDeleted += new WeakEventHandler <Guid>(AccountsManager_OnAccountDeleted).Handler;

            var lastLoginLocalId = AccountsManager.GetLastLoginLocalId();

            if (lastLoginLocalId != Guid.Empty)
            {
                var lastLogin = Accounts.FirstOrDefault(i => i.LocalAccountId == lastLoginLocalId);

                if (lastLogin != null && lastLogin.RememberUsername && !lastLogin.IsDefaultOfflineAccount)
                {
                    Username = lastLogin.Username;
                }
            }
        }
        public void Test001()
        {
            MyObservableList <string> people = new MyObservableList <string>()
            {
                "Andrew",
                "Lei",
                "Matt"
            };

            MyObservableList <string> filteredPeople = people.Sublist(i => i.StartsWith("a", StringComparison.CurrentCultureIgnoreCase), SublistSortOption.SameAsParentList);

            AssertListsEqual(new string[] { "Andrew" }, filteredPeople);

            people.Add("Adam");

            /// Andrew
            /// Lei
            /// Matt
            /// Adam

            AssertListsEqual(new string[] { "Andrew", "Adam" }, filteredPeople);

            people.Insert(0, "Andrea");

            /// Andrea
            /// Andrew
            /// Lei
            /// Matt
            /// Adam

            AssertListsEqual(new string[] { "Andrea", "Andrew", "Adam" }, filteredPeople);

            people.Insert(3, "Austin");

            /// Andrea
            /// Andrew
            /// Lei
            /// Austin
            /// Matt
            /// Adam

            AssertListsEqual(new string[] { "Andrea", "Andrew", "Austin", "Adam" }, filteredPeople);

            people.RemoveAt(2);

            /// Andrea
            /// Andrew
            /// Austin
            /// Matt
            /// Adam

            AssertListsEqual(new string[] { "Andrea", "Andrew", "Austin", "Adam" }, filteredPeople);

            people.Insert(2, "Thomas");

            /// Andrea
            /// Andrew
            /// Thomas
            /// Austin
            /// Matt
            /// Adam

            AssertListsEqual(new string[] { "Andrea", "Andrew", "Austin", "Adam" }, filteredPeople);

            people.Insert(0, "Frank");

            /// Frank
            /// Andrea
            /// Andrew
            /// Thomas
            /// Austin
            /// Matt
            /// Adam

            AssertListsEqual(new string[] { "Andrea", "Andrew", "Austin", "Adam" }, filteredPeople);

            people.Add("Steve");

            /// Frank
            /// Andrea
            /// Andrew
            /// Thomas
            /// Austin
            /// Matt
            /// Adam
            /// Steve

            AssertListsEqual(new string[] { "Andrea", "Andrew", "Austin", "Adam" }, filteredPeople);

            people.RemoveAt(1);

            /// Frank
            /// Andrew
            /// Thomas
            /// Austin
            /// Matt
            /// Adam
            /// Steve

            AssertListsEqual(new string[] { "Andrew", "Austin", "Adam" }, filteredPeople);

            people.RemoveAt(3);

            /// Frank
            /// Andrew
            /// Thomas
            /// Matt
            /// Adam
            /// Steve

            AssertListsEqual(new string[] { "Andrew", "Adam" }, filteredPeople);

            people.Clear();

            AssertListsEqual(new string[0], filteredPeople);
        }