Example #1
0
        public static int CompareByFetchUrl(RemoteListItem item1, RemoteListItem item2)
        {
            var data1 = item1.DataContext.FetchUrl;
            var data2 = item2.DataContext.FetchUrl;

            return(string.Compare(data1, data2));
        }
Example #2
0
        public static int CompareByName(RemoteListItem item1, RemoteListItem item2)
        {
            var data1 = item1.DataContext.Name;
            var data2 = item2.DataContext.Name;

            return(string.Compare(data1, data2));
        }
Example #3
0
        public static int UniversalComparer(CustomListBoxItem item1, CustomListBoxItem item2)
        {
            if (item1.GetType() == item2.GetType())
            {
                switch (item1)
                {
                case BranchListItem branchItem:
                    return(BranchListItem.CompareByName(branchItem, (BranchListItem)item2));

                case RemoteBranchListItem remoteBranchItem:
                    return(RemoteBranchListItem.CompareByName(remoteBranchItem, (RemoteBranchListItem)item2));

                case RemoteListItem remoteItem:
                    return(RemoteListItem.CompareByName(remoteItem, (RemoteListItem)item2));

                case TagListItem tagItem:
                    return(TagListItem.CompareByName(tagItem, (TagListItem)item2));

                default: return(0);
                }
            }
            else
            {
                switch (item1)
                {
                case BranchListItem _:       return(-1);

                case RemoteBranchListItem _: return(item2 is BranchListItem ? 1 : -1);

                case RemoteListItem _:       return(item2 is TagListItem ? 1 : -1);

                default: return(1);
                }
            }
        }
Example #4
0
 private RemoteListItem GetRemoteListItem(RemoteBranch branch)
 {
     lock (Repository.Remotes.SyncRoot)
     {
         foreach (var remote in Repository.Remotes)
         {
             if (branch.Name.StartsWith(remote.Name + "/"))
             {
                 RemoteListItem ritem = null;
                 foreach (var i in _remotes)
                 {
                     if (i.DataContext.Name == remote.Name)
                     {
                         ritem = i;
                         break;
                     }
                 }
                 if (ritem == null)
                 {
                     ritem = new RemoteListItem(remote);
                     ritem.Items.Comparison = RemoteBranchListItem.CompareByName;
                     _remotes.Add(ritem);
                     CustomListBoxItemsCollection host;
                     if (Remotes == null)
                     {
                         host = _itemHost;
                     }
                     else
                     {
                         host = Remotes.Items;
                     }
                     host.AddSafe(ritem);
                 }
                 return(ritem);
             }
         }
     }
     return(null);
 }
Example #5
0
 public static int UniversalComparer(CustomListBoxItem item1, CustomListBoxItem item2)
 {
     if (item1.GetType() == item2.GetType())
     {
         var branchItem = item1 as BranchListItem;
         if (branchItem != null)
         {
             return(BranchListItem.CompareByName(branchItem, (BranchListItem)item2));
         }
         var remoeBranchItem = item1 as RemoteBranchListItem;
         if (remoeBranchItem != null)
         {
             return(RemoteBranchListItem.CompareByName(branchItem, (RemoteBranchListItem)item2));
         }
         var remoteItem = item1 as RemoteListItem;
         if (remoteItem != null)
         {
             return(RemoteListItem.CompareByName(remoteItem, (RemoteListItem)item2));
         }
         var tagItem = item1 as TagListItem;
         if (tagItem != null)
         {
             return(TagListItem.CompareByName(tagItem, (TagListItem)item2));
         }
         return(0);
     }
     else
     {
         var branchItem = item1 as BranchListItem;
         if (branchItem != null)
         {
             return(-1);
         }
         var remoteBranchItem = item1 as RemoteBranchListItem;
         if (remoteBranchItem != null)
         {
             var branchItem2 = item2 as BranchListItem;
             if (branchItem2 != null)
             {
                 return(1);
             }
             else
             {
                 return(-1);
             }
         }
         var remoteListItem = item1 as RemoteListItem;
         if (remoteListItem != null)
         {
             var tagItem2 = item2 as TagListItem;
             if (tagItem2 == null)
             {
                 return(-1);
             }
             else
             {
                 return(1);
             }
         }
         return(1);
     }
 }