コード例 #1
0
        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;
                }
            });
        }
コード例 #2
0
 private static IdAttribute GetAttr(EPlugin p)
 => (IdAttribute)Attribute.GetCustomAttribute(ForValue(p), typeof(IdAttribute));
コード例 #3
0
 private static MemberInfo ForValue(EPlugin p)
 => typeof(EPlugin).GetField(Enum.GetName(typeof(EPlugin), p));
コード例 #4
0
        public static string GetName(this EPlugin p)
        {
            var attr = GetAttr(p);

            return(attr.Name);
        }