我有丰富的Java背景,所以如果我在C#中忽略了一些显而易见的东西,请原谅我,但是我的研究却毫无进展。我正在尝试使用反应式Rx .NET库。编译器对 IObservable
没有抱怨,但对于调用 zip
方法则有。它会抛出“……是否缺少 using 指令或程序集引用?”。
我一直在查找命名空间,但找不到所需的内容。我也找不到 System.Reactive
,如果使用它也会报错,而且所有的引用都已经包含在这个Windows 8.1应用程序中了。请问有人可以给我指点一下出了什么问题吗?
public sealed class EventEngine
{
private static readonly EventEngine singleton = new EventEngine();
public static EventEngine get()
{
return singleton;
}
public IObservable<MusicNote> CurrentKey { get; set; }
public IObservable<Scale> CurrentScale { get; set; }
public IObservable<AppliedScale> CurrentAppliedScale
{
get
{
return CurrentScale.zip(CurrentKey,
(s, k) => AppliedScale.getAppliedScale(k, s));
}
}
private EventEngine() {}
}
*更新*
在考虑了答案的反馈后,这是可行的版本。
public sealed class EventEngine
{
private static readonly EventEngine singleton = new EventEngine();
public static EventEngine get()
{
return singleton;
}
public IObservable<MusicNote> CurrentKey { get; set; }
public IObservable<Scale> CurrentScale { get; set; }
public IObservable<AppliedScale> CurrentAppliedScale
{
get
{
return Observable.Zip(CurrentScale, CurrentKey,
(s, k) => AppliedScale.getAppliedScale(s,k));
}
}
private EventEngine() {}
}
Scale
类吗? - David Tansey