Checkpoint

This commit is contained in:
2020-05-01 05:08:04 -04:00
parent abba062f4f
commit 1a394ddb31
20 changed files with 239 additions and 102 deletions

View File

@@ -1,27 +1,24 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using Foodsoft.Alpm;
// ReSharper disable once UnusedType.Global
namespace Samples
{
[Example("installed")]
internal class Installed : IExample
{
private static string ModToStr(Depend.ModType modType)
private static string ModToStr(ModType modType)
{
return modType switch
{
Depend.ModType.Any => "",
Depend.ModType.Equal => "==",
Depend.ModType.GreaterThanOrEqual => ">=",
Depend.ModType.LessThanOrEqual => "<=",
Depend.ModType.GreaterThan => ">",
Depend.ModType.LessThan => "<",
ModType.Any => "",
ModType.Equal => "==",
ModType.GreaterThanOrEqual => ">=",
ModType.LessThanOrEqual => "<=",
ModType.GreaterThan => ">",
ModType.LessThan => "<",
_ => throw new ArgumentOutOfRangeException(nameof(modType), modType, null)
};
}
@@ -60,7 +57,7 @@ namespace Samples
//using var pkg = db.PackageCache.FindSatisfier("gcc=9.3.0-1");
var result = db.Search(new string[] {"gcc", "objc"});
var result = db.Search(new[] {"gcc", "objc"});
foreach (var pkg in result)
using (pkg)
{
@@ -82,7 +79,7 @@ namespace Samples
var examples = (from t in Assembly.GetExecutingAssembly().GetTypes()
let attribute = (Example?) t.GetCustomAttribute(typeof(Example))
where attribute != null
select new {Name = attribute.Name, Type = t}).ToImmutableDictionary((e) => e.Name);
select new {attribute.Name, Type = t}).ToImmutableDictionary((e) => e.Name);
if (args.Length < 1)
{
@@ -110,7 +107,7 @@ namespace Samples
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false)]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
public class Example : Attribute
{
public string Name { get; }