public PluginViewModel( EPlugin plugin, Package package, ReleaseModel releaseModel, ITaskService taskService, string installPath) { _taskService = taskService; Plugin = plugin; InstallPath = installPath; ReleaseModel = releaseModel; Package = package; Name = package.Name; Description = package.Description; InstallCommand = ReactiveCommand.Create(InstallAsync, this.WhenAnyValue(x => x.IsBusy, x => x.ReleaseModel, (busy, model) => !busy && model != null)); OpenCommand = ReactiveCommand.Create(OpenAsync); RemoveCommand = ReactiveCommand.Create(RemoveAsync); this.WhenAnyValue(x => x.Status).Subscribe(status => { switch (status) { case EPluginStatus.NotInstalled: IsOpenEnabled = false; IsNotInstalled = true; Label = "Install"; break; case EPluginStatus.Outdated: IsOpenEnabled = true; IsNotInstalled = false; Label = "Update"; break; case EPluginStatus.Latest: IsOpenEnabled = true; IsNotInstalled = false; Label = "Repair"; break; default: break; } }); }
private static IdAttribute GetAttr(EPlugin p) => (IdAttribute)Attribute.GetCustomAttribute(ForValue(p), typeof(IdAttribute));
private static MemberInfo ForValue(EPlugin p) => typeof(EPlugin).GetField(Enum.GetName(typeof(EPlugin), p));
public static string GetName(this EPlugin p) { var attr = GetAttr(p); return(attr.Name); }