本文整理汇总了C#中Class1.Bind方法的典型用法代码示例。如果您正苦于以下问题:C# Class1.Bind方法的具体用法?C# Class1.Bind怎么用?C# Class1.Bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Class1
的用法示例。
在下文中一共展示了Class1.Bind方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Binding_To_UnsetValue_Doesnt_Throw
public void Binding_To_UnsetValue_Doesnt_Throw()
{
var target = new Class1();
var source = new Subject<object>();
target.Bind(Class1.QuxProperty, source);
source.OnNext(AvaloniaProperty.UnsetValue);
}
示例2: BindingError_With_FallbackValue_Causes_Target_Update
public void BindingError_With_FallbackValue_Causes_Target_Update()
{
var target = new Class1();
var source = new Subject<object>();
target.Bind(Class1.FooProperty, source);
source.OnNext("initial");
source.OnNext(new BindingError(new InvalidOperationException("Foo"), "fallback"));
Assert.Equal("fallback", target.GetValue(Class1.FooProperty));
}
示例3: Binding_To_Direct_Property_Does_Not_Get_Collected
public void Binding_To_Direct_Property_Does_Not_Get_Collected()
{
var target = new Class1();
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);
}
示例4: Binding_To_Direct_Property_Gets_Collected_When_Completed
public void Binding_To_Direct_Property_Gets_Collected_When_Completed()
{
var target = new Class1();
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);
}
示例5: ReadOnly_Property_Cannot_Be_Bound_NonGeneric
public void ReadOnly_Property_Cannot_Be_Bound_NonGeneric()
{
var target = new Class1();
var source = new Subject<string>();
Assert.Throws<ArgumentException>(() =>
target.Bind(Class1.BarProperty, source));
}
示例6: Bind_Handles_Wrong_Value_Type
public void Bind_Handles_Wrong_Value_Type()
{
var target = new Class1();
var source = new Subject<object>();
var sub = target.Bind(Class1.BazProperty, source);
source.OnNext("foo");
Assert.Equal(0, target.Baz);
}
示例7: Bind_Handles_Wrong_Type
public void Bind_Handles_Wrong_Type()
{
var target = new Class1();
var source = new Subject<object>();
var sub = target.Bind(Class1.FooProperty, source);
source.OnNext(45);
Assert.Equal(null, target.Foo);
}
示例8: Bind_NonGeneric_Coerces_UnsetValue
public void Bind_NonGeneric_Coerces_UnsetValue()
{
var target = new Class1();
var source = new Subject<object>();
var sub = target.Bind((PerspexProperty)Class1.BazProperty, source);
Assert.Equal(5, target.Baz);
source.OnNext(6);
Assert.Equal(6, target.Baz);
source.OnNext(PerspexProperty.UnsetValue);
Assert.Equal(0, target.Baz);
}
示例9: Bind_Binds_Property_Value_NonGeneric
public void Bind_Binds_Property_Value_NonGeneric()
{
var target = new Class1();
var source = new Subject<string>();
var sub = target.Bind((PerspexProperty)Class1.FooProperty, source);
Assert.Equal("initial", 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);
}
示例10: Binding_To_Direct_Property_Logs_BindingError
public void Binding_To_Direct_Property_Logs_BindingError()
{
var target = new Class1();
var source = new Subject<object>();
var called = false;
LogCallback checkLogMessage = (level, area, src, mt, pv) =>
{
if (level == LogEventLevel.Error &&
area == LogArea.Binding &&
mt == "Error in binding to {Target}.{Property}: {Message}" &&
pv.Length == 3 &&
pv[0] is Class1 &&
object.ReferenceEquals(pv[1], Class1.FooProperty) &&
(string)pv[2] == "Binding Error Message")
{
called = true;
}
};
using (TestLogSink.Start(checkLogMessage))
{
target.Bind(Class1.FooProperty, source);
source.OnNext("baz");
source.OnNext(new BindingNotification(new InvalidOperationException("Binding Error Message"), BindingErrorType.Error));
}
Assert.True(called);
}
示例11: BindingError_Does_Not_Cause_Target_Update
public void BindingError_Does_Not_Cause_Target_Update()
{
var target = new Class1();
var source = new Subject<object>();
target.Bind(Class1.FooProperty, source);
source.OnNext("initial");
source.OnNext(new BindingNotification(new InvalidOperationException("Foo"), BindingErrorType.Error));
Assert.Equal("initial", target.GetValue(Class1.FooProperty));
}
示例12: Bind_Handles_UnsetValue
public void Bind_Handles_UnsetValue()
{
var target = new Class1();
var source = new Subject<object>();
var sub = target.Bind(Class1.BazProperty, source);
source.OnNext(PerspexProperty.UnsetValue);
Assert.Equal(0, target.Baz);
}