diff --git a/VisualTeensy/ViewModel/LibrariesTab/LibraryVM.cs b/VisualTeensy/ViewModel/LibrariesTab/LibraryVM.cs index 4833a2f..b0c4f6a 100644 --- a/VisualTeensy/ViewModel/LibrariesTab/LibraryVM.cs +++ b/VisualTeensy/ViewModel/LibrariesTab/LibraryVM.cs @@ -2,6 +2,7 @@ using vtCore; using System.Linq; using vtCore.Interfaces; +using System; namespace ViewModel { @@ -13,15 +14,48 @@ public class LibraryVM : BaseViewModel //public string parentRepository { get; } public ILibrary selectedVersion { get; set; } - + public LibraryVM(IEnumerable lib/*, string repositoryName*/) { //parentRepository = string.IsNullOrWhiteSpace(repositoryName) ? "?" : repositoryName; - this.versions = lib.OrderBy(v => v.version).ToList(); - selectedVersion = this.versions.LastOrDefault(); + this.versions = lib.OrderByDescending(v => v.v).ToList(); + + + selectedVersion = this.versions.FirstOrDefault(); } public override string ToString() => name; + + + } } + + //public class SortPara : IComparable + //{ + // public List numbers { get; set; } + // public string strNumbers { get; set; } + // public SortPara(string strNumbers) + // { + // this.strNumbers = strNumbers; + // numbers = strNumbers.Split(new char[] { '.' }).Select(x => int.Parse(x)).ToList(); + + // } + // public int CompareTo(SortPara other) + // { + // int shortest = this.numbers.Count < other.numbers.Count ? this.numbers.Count : other.numbers.Count; + // int results = 0; + // for (int i = 0; i < shortest; i++) + // { + // if (this.numbers[i] != other.numbers[i]) + // { + // results = this.numbers[i].CompareTo(other.numbers[i]); + // break; + // } + // } + // return results; + // } + //} + + diff --git a/vtCore/Implementation/Libraries/Library.cs b/vtCore/Implementation/Libraries/Library.cs index 92e2db7..3d38b72 100644 --- a/vtCore/Implementation/Libraries/Library.cs +++ b/vtCore/Implementation/Libraries/Library.cs @@ -7,9 +7,21 @@ namespace vtCore { public class Library : ILibrary - { + { public string name { get; set; } // name, can contain spaces public string version { get; set; } // more than one version of the lib can be found in repos + public Version v // experimental, replace version string by version if this works out + { + get + { + if(Version.TryParse(version, out Version ver)) + { + return ver; + } + return new Version(); + } + } + public string author { get; set; } // no format requirements public string maintainer { get; set; } // no format requirements public string sentence { get; set; } // short description @@ -30,8 +42,8 @@ public class Library : ILibrary protected Library(ILibrary copyMe) { - Type t = copyMe.GetType(); - foreach (PropertyInfo propInf in t.GetProperties().Where(p=>p.SetMethod != null)) + Type t = copyMe.GetType(); + foreach (PropertyInfo propInf in t.GetProperties().Where(p => p.SetMethod != null)) { propInf.SetValue(this, propInf.GetValue(copyMe)); } diff --git a/vtCore/Implementation/Libraries/LibraryReader.cs b/vtCore/Implementation/Libraries/LibraryReader.cs index 4243ab0..00dbe15 100644 --- a/vtCore/Implementation/Libraries/LibraryReader.cs +++ b/vtCore/Implementation/Libraries/LibraryReader.cs @@ -46,7 +46,7 @@ public static ILookup parseIndexJsonRepository(string library_ var ret = jsonLibs.Select(t => new Library() { name = t.name, - version = t.version, + version = t.version, author = t.author, maintainer = t.maintainer, sentence = t.sentence, diff --git a/vtCore/Interfaces/ILibrary.cs b/vtCore/Interfaces/ILibrary.cs index 77f78e2..0abd5c6 100644 --- a/vtCore/Interfaces/ILibrary.cs +++ b/vtCore/Interfaces/ILibrary.cs @@ -21,6 +21,7 @@ public interface ILibrary Uri sourceUri { get; } List types { get; } string version { get; } + Version v { get; } string website { get; } string ToString(); }