本文整理汇总了C#中Class1.GetObservable方法的典型用法代码示例。如果您正苦于以下问题:C# Class1.GetObservable方法的具体用法?C# Class1.GetObservable怎么用?C# Class1.GetObservable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Class1
的用法示例。
在下文中一共展示了Class1.GetObservable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Later_Styles_Should_Override_Earlier
public void Later_Styles_Should_Override_Earlier()
{
Styles styles = new Styles
{
new Style(x => x.OfType<Class1>().Class("foo"))
{
Setters = new[]
{
new Setter(Class1.FooProperty, "Foo"),
},
},
new Style(x => x.OfType<Class1>().Class("foo"))
{
Setters = new[]
{
new Setter(Class1.FooProperty, "Bar"),
},
}
};
var target = new Class1();
List<string> values = new List<string>();
target.GetObservable(Class1.FooProperty).Subscribe(x => values.Add(x));
styles.Attach(target);
target.Classes.Add("foo");
target.Classes.Remove("foo");
Assert.Equal(new[] { "foodefault", "Foo", "Bar", "foodefault" }, values);
}
示例2: GetObservable_Returns_Property_Change
public void GetObservable_Returns_Property_Change()
{
Class1 target = new Class1();
bool raised = false;
target.GetObservable(Class1.FooProperty).Subscribe(x => raised = x == "newvalue");
raised = false;
target.SetValue(Class1.FooProperty, "newvalue");
Assert.True(raised);
}
示例3: GetObservable_Dispose_Stops_Property_Changes
public void GetObservable_Dispose_Stops_Property_Changes()
{
Class1 target = new Class1();
bool raised = false;
target.GetObservable(Class1.FooProperty)
.Subscribe(x => raised = true)
.Dispose();
raised = false;
target.SetValue(Class1.FooProperty, "newvalue");
Assert.False(raised);
}
示例4: GetObservable_Returns_Initial_Value
public void GetObservable_Returns_Initial_Value()
{
Class1 target = new Class1();
int raised = 0;
target.GetObservable(Class1.FooProperty).Subscribe(x =>
{
if (x == "foodefault")
{
++raised;
}
});
Assert.Equal(1, raised);
}
示例5: GetObservable_Returns_Values
public void GetObservable_Returns_Values()
{
var target = new Class1();
List<string> values = new List<string>();
target.GetObservable(Class1.FooProperty).Subscribe(x => values.Add(x));
target.Foo = "newvalue";
Assert.Equal(new[] { "initial", "newvalue" }, values);
}