private void CollectionFromItemsString(string type)
        {
            if (type == "Authors")
            {
                // 1. Clear the collections
                AuthorsCollection.Clear();

                // 2. Check if items string is blank
                if (String.IsNullOrWhiteSpace(Authors))
                {
                    return;
                }

                // 3. Add each item from item string into collection
                foreach (string author in Authors.Split(new string[] { ", " }, StringSplitOptions.None))
                {
                    AuthorsCollection.Add(author);
                }
            }
            else if (type == "Keywords")
            {
                KeywordsCollection.Clear();

                if (String.IsNullOrWhiteSpace(Keywords))
                {
                    return;
                }

                foreach (string keyword in Keywords.Split(new string[] { ", " }, StringSplitOptions.None))
                {
                    KeywordsCollection.Add(keyword);
                }
            }
        }
 public void Clear()
 {
     ID              = null;
     Title           = null;
     Authors         = null;
     Keywords        = null;
     Year            = null;
     FileName        = null;
     PersonalComment = null;
     SIC             = 0;
     AuthorsCollection.Clear();
     KeywordsCollection.Clear();
 }
        private void ItemsStringFromCollection(string type)
        {
            if (type == "Authors")
            {
                // 1. Clear the items string
                Authors = "";

                // 2. Check if collection is empty
                if (AuthorsCollection.Count <= 0)
                {
                    return;
                }

                // 3. Build string from each item in collection
                foreach (string author in AuthorsCollection)
                {
                    Authors += author;

                    // If current author is not the last one add separator ', '
                    if (author != AuthorsCollection.Last())
                    {
                        Authors += ", ";
                    }
                }
            }
            else if (type == "Keywords")
            {
                Keywords = "";

                if (KeywordsCollection.Count <= 0)
                {
                    return;
                }

                foreach (string keyword in KeywordsCollection)
                {
                    Keywords += keyword;

                    if (keyword != KeywordsCollection.Last())
                    {
                        Keywords += ", ";
                    }
                }
            }
        }
示例#4
0
        private async void GetAuthors()
        {
            AuthorsCollection.Clear();

            await Task.Run(() =>
            {
                this.SelectedRepositories.ForEach(selectedRepository =>
                {
                    using (var session = DbService.Instance.SessionFactory.OpenSession())
                    {
                        if (string.IsNullOrEmpty(selectedRepository))
                        {
                            var authors =
                                session.QueryOver <Commit>()
                                .SelectList(list => list.SelectGroup(commit => commit.Author))
                                .List <string>();
                            authors.ForEach(author => AuthorsCollection.Add(author));
                        }
                        else
                        {
                            Branch branch         = null;
                            Repository repository = null;
                            var authors           =
                                session.QueryOver <Commit>()
                                .SelectList(list => list.SelectGroup(commit => commit.Author))
                                .JoinAlias(commit => commit.Branches, () => branch, JoinType.InnerJoin)
                                .JoinAlias(() => branch.Repository, () => repository, JoinType.InnerJoin)
                                .Where(() => repository.Name == selectedRepository).List <string>();

                            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                            {
                                authors.ForEach(author => AuthorsCollection.Add(author));
                            }));
                        }
                    }
                });
            });
        }