1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SourceBrowser.Search.ViewModels
{
    public struct TokenViewModel
    {
        public string Id { get; } 

        public string Path { get; } 
        public string Username { get; }
        public string Repository { get; }
        public string FullyQualifiedName { get; }
        public string DisplayName
        {
            get
            {
                if (FullyQualifiedName == null)
                    return null;
                string currentName = FullyQualifiedName;
                var parensIndex = FullyQualifiedName.IndexOf("(");
                if(parensIndex != -1)
                {
                    currentName = currentName.Remove(parensIndex, currentName.Length - parensIndex);
                }

                var splitName = currentName.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                return splitName.Last();
            }
        }
        public int LineNumber { get; }

        public TokenViewModel(string username, string repository, string path, string fullName, int lineNumber)
        {
            Id = username + "/" + repository + "/" + fullName;
            Username = username;
            Repository = repository;
            Path = path;
            FullyQualifiedName = fullName;
            LineNumber = lineNumber;
        }
    }
}