C# 显然,如果没有实现,ReactiveCommand如何从ICommand派生?
在C# 显然,如果没有实现,ReactiveCommand如何从ICommand派生?,c#,reactiveui,C#,Reactiveui,在ReactiveUI中,类ReactiveCommand来自接口ICommand。然而,它的公共API似乎没有实现Execute和CanExecute 这怎么可能呢?ReactiveCommand实现了ICommand,这意味着只有当您的变量键入为ICommand时,您才能访问这些成员: ReactiveCommand<Unit, Unit> command = ...; // compile error command.Execute(); // compiles fine
ReactiveUI
中,类ReactiveCommand
来自接口ICommand
。然而,它的公共API似乎没有实现Execute
和CanExecute
这怎么可能呢?
ReactiveCommand
实现了ICommand
,这意味着只有当您的变量键入为ICommand
时,您才能访问这些成员:
ReactiveCommand<Unit, Unit> command = ...;
// compile error
command.Execute();
// compiles fine
(command as ICommand).Execute();
ReactiveCommand=。。。;
//编译错误
command.Execute();
//编撰精良
(命令作为ICommand.Execute();
这是为了鼓励您不要使用它,因为反应式界面优越,但仍有助于与依赖于它的UI工具包(如WPF)集成。
ReactiveCommand
实现了ICommand
,这意味着您只能在变量类型为ICommand
时访问这些成员:
ReactiveCommand<Unit, Unit> command = ...;
// compile error
command.Execute();
// compiles fine
(command as ICommand).Execute();
ReactiveCommand=。。。;
//编译错误
command.Execute();
//编撰精良
(命令作为ICommand.Execute();
这是为了鼓励您不要使用它,因为反应式界面更优越,但仍有助于与依赖它的UI工具包(如WPF)的集成.我从来不知道接口的显式实现不会出现在类API中。我从来不知道接口的显式实现不会出现在类API中。