本文整理汇总了C#中Class2.Bind方法的典型用法代码示例。如果您正苦于以下问题:C# Class2.Bind方法的具体用法?C# Class2.Bind怎么用?C# Class2.Bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Class2
的用法示例。
在下文中一共展示了Class2.Bind方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Binding_To_Direct_Property_Does_Not_Get_Collected
public void Binding_To_Direct_Property_Does_Not_Get_Collected()
{
var target = new Class2();
Func<WeakReference> setupBinding = () =>
{
var source = new Subject<string>();
var sub = target.Bind((AvaloniaProperty)Class1.FooProperty, source);
source.OnNext("foo");
return new WeakReference(source);
};
var weakSource = setupBinding();
GC.Collect();
Assert.Equal("foo", target.Foo);
Assert.True(weakSource.IsAlive);
}
示例2: Binding_To_Direct_Property_Gets_Collected_When_Completed
public void Binding_To_Direct_Property_Gets_Collected_When_Completed()
{
var target = new Class2();
Func<WeakReference> setupBinding = () =>
{
var source = new Subject<string>();
var sub = target.Bind((AvaloniaProperty)Class1.FooProperty, source);
return new WeakReference(source);
};
var weakSource = setupBinding();
Action completeSource = () =>
{
((ISubject<string>)weakSource.Target).OnCompleted();
};
completeSource();
GC.Collect();
Assert.False(weakSource.IsAlive);
}
示例3: Bind_Binds_AddOwnered_Property_Value_NonGeneric
public void Bind_Binds_AddOwnered_Property_Value_NonGeneric()
{
var target = new Class2();
var source = new Subject<string>();
var sub = target.Bind((PerspexProperty)Class1.FooProperty, source);
Assert.Equal("initial2", target.Foo);
source.OnNext("first");
Assert.Equal("first", target.Foo);
source.OnNext("second");
Assert.Equal("second", target.Foo);
sub.Dispose();
source.OnNext("third");
Assert.Equal("second", target.Foo);
}