本文整理汇总了C#中DataBinding类的典型用法代码示例。如果您正苦于以下问题:C# DataBinding类的具体用法?C# DataBinding怎么用?C# DataBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataBinding类属于命名空间,在下文中一共展示了DataBinding类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HandlesDegenerateCaseWithOneProvider
public void HandlesDegenerateCaseWithOneProvider()
{
DataBinding[] bindings = new DataBinding[] {
new DataBinding(0, null)
};
IDataProvider[] providers = new IDataProvider[] {
Mocks.StrictMock<IDataProvider>()
};
using (Mocks.Record())
{
Expect.Call(providers[0].GetItems(bindings, true)).Return(new IDataItem[] {
new ScalarDataItem<int>(1, null, true),
new ScalarDataItem<int>(2, null, false),
new ScalarDataItem<int>(3, null, true)
});
}
using (Mocks.Playback())
{
List<IDataItem> items = new List<IDataItem>(IntersectionMergeStrategy.Instance.Merge(providers, bindings, true));
Assert.Count(3, items);
Assert.AreEqual(1, items[0].GetValue(bindings[0]));
Assert.IsTrue(items[0].IsDynamic);
Assert.AreEqual(2, items[1].GetValue(bindings[0]));
Assert.IsFalse(items[1].IsDynamic);
Assert.AreEqual(3, items[2].GetValue(bindings[0]));
Assert.IsTrue(items[2].IsDynamic);
}
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:33,代码来源:IntersectionMergeStrategyTest.cs
示例2: GetValue
/// <inheritdoc />
public object GetValue(DataBinding binding)
{
if (binding == null)
throw new ArgumentNullException("binding");
return GetValueImpl(binding);
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:8,代码来源:BaseDataItem.cs
示例3: HandlesDegenerateCaseWithMoreThanOneProviderButOneIsEmpty
public void HandlesDegenerateCaseWithMoreThanOneProviderButOneIsEmpty()
{
DataBinding[][] bindingsPerProvider = new DataBinding[][] {
new DataBinding[] { new DataBinding(0, null) },
new DataBinding[] { new DataBinding(0, null) },
};
IDataProvider[] providers = new IDataProvider[] {
Mocks.StrictMock<IDataProvider>(),
Mocks.StrictMock<IDataProvider>()
};
IDataItem[][] itemsPerProvider = new IDataItem[][] {
new IDataItem[] {
new ScalarDataItem<int>(1, null, true),
new ScalarDataItem<int>(2, null, false)
},
new IDataItem[0]
};
using (Mocks.Record())
{
SetupResult.For(providers[0].GetItems(bindingsPerProvider[0], true)).Return(itemsPerProvider[0]);
SetupResult.For(providers[1].GetItems(bindingsPerProvider[1], true)).Return(itemsPerProvider[1]);
}
using (Mocks.Playback())
{
List<IList<IDataItem>> items = new List<IList<IDataItem>>(PairwiseJoinStrategy.Instance.Join(providers, bindingsPerProvider, true));
Assert.Count(0, items);
}
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:32,代码来源:PairwiseJoinStrategyTest.cs
示例4: BoundDataAccessor
/// <summary>
/// Creates a bound data accessor.
/// </summary>
/// <param name="binding">The binding to query.</param>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="binding"/> is null.</exception>
public BoundDataAccessor(DataBinding binding)
{
if (binding == null)
throw new ArgumentNullException("binding");
this.binding = binding;
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:12,代码来源:BoundDataAccessor.cs
示例5: CanBind
/// <inheritdoc />
public bool CanBind(DataBinding binding)
{
if (binding == null)
throw new ArgumentNullException("binding");
return CanBindImpl(binding);
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:8,代码来源:BaseDataSet.cs
示例6: ConstructorWithPathAndIndex
public void ConstructorWithPathAndIndex()
{
DataBinding binding = new DataBinding(42, "path");
Assert.AreEqual("path", binding.Path);
Assert.AreEqual(42, binding.Index);
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:7,代码来源:DataBindingTest.cs
示例7: AccessorObtainsAValueFromTheRow
public void AccessorObtainsAValueFromTheRow()
{
DataBinding binding = new DataBinding(0, null);
ScalarDataBinder binder = new ScalarDataBinder(binding, "name");
IDataSourceResolver resolver = Mocks.StrictMock<IDataSourceResolver>();
DataBindingContext context = new DataBindingContext(new NullConverter());
DataSource source = new DataSource("name");
source.AddDataSet(new ItemSequenceDataSet(new IDataItem[]
{
new ScalarDataItem<int>(42, null, false),
new ScalarDataItem<string>("42", null, false)
}, 1));
using (Mocks.Record())
{
Expect.Call(resolver.ResolveDataSource("name")).Return(source);
}
using (Mocks.Playback())
{
IDataAccessor accessor = binder.Register(context, resolver);
Assert.IsTrue(context.DataSets.Contains(source), "The data sets list should contain the source that was resolved during binder registration.");
List<IDataItem> items = new List<IDataItem>(context.GetItems(true));
Assert.Count(2, items);
Assert.AreEqual(42, accessor.GetValue(items[0]));
Assert.AreEqual("42", accessor.GetValue(items[1]));
}
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:32,代码来源:ScalarDataBinderTest.cs
示例8: JoinsItemsCombinatorially
public void JoinsItemsCombinatorially()
{
DataBinding[][] bindingsPerProvider = new DataBinding[][] {
new DataBinding[] { new DataBinding(0, null) },
new DataBinding[] { },
new DataBinding[] { new DataBinding(0, null) },
};
IDataProvider[] providers = new IDataProvider[] {
Mocks.StrictMock<IDataProvider>(),
Mocks.StrictMock<IDataProvider>(),
Mocks.StrictMock<IDataProvider>()
};
IDataItem[][] itemsPerProvider = new IDataItem[][] {
new IDataItem[] {
new ScalarDataItem<int>(1, null, false),
new ScalarDataItem<int>(2, null, true)
},
new IDataItem[] {
new ScalarDataItem<int>(1, null, false),
new ScalarDataItem<int>(2, null, false),
new ScalarDataItem<int>(3, null, false)
},
new IDataItem[] {
new ScalarDataItem<int>(1, null, false),
new ScalarDataItem<int>(2, null, true)
}
};
using (Mocks.Record())
{
Expect.Call(providers[0].GetItems(bindingsPerProvider[0], true)).Return(itemsPerProvider[0]);
Expect.Call(providers[1].GetItems(bindingsPerProvider[1], true)).Return(itemsPerProvider[1]);
Expect.Call(providers[2].GetItems(bindingsPerProvider[2], true)).Return(itemsPerProvider[2]);
}
using (Mocks.Playback())
{
List<IList<IDataItem>> items = new List<IList<IDataItem>>(CombinatorialJoinStrategy.Instance.Join(providers, bindingsPerProvider, true));
Assert.Count(12, items);
int index = 0;
for (int i = 0; i < itemsPerProvider[0].Length; i++)
{
for (int j = 0; j < itemsPerProvider[1].Length; j++)
{
for (int k = 0; k < itemsPerProvider[2].Length; k++)
{
Assert.AreSame(itemsPerProvider[0][i], items[index][0]);
Assert.AreSame(itemsPerProvider[1][j], items[index][1]);
Assert.AreSame(itemsPerProvider[2][k], items[index][2]);
index += 1;
}
}
}
}
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:59,代码来源:CombinatorialJoinStrategyTest.cs
示例9: HandlesDegenerateCaseWithZeroProviders
public void HandlesDegenerateCaseWithZeroProviders()
{
DataBinding[][] bindingsPerProvider = new DataBinding[0][];
IDataProvider[] providers = new IDataProvider[0];
List<IList<IDataItem>> items = new List<IList<IDataItem>>(PairwiseJoinStrategy.Instance.Join(providers, bindingsPerProvider, true));
Assert.Count(0, items);
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:8,代码来源:PairwiseJoinStrategyTest.cs
示例10: KeepsOnlyIntersectionIncludingRightNumberOfDuplicatesAndExcludesBadItems
public void KeepsOnlyIntersectionIncludingRightNumberOfDuplicatesAndExcludesBadItems()
{
DataBinding[] bindings = new DataBinding[] {
new DataBinding(0, null)
};
IDataProvider[] providers = new IDataProvider[] {
Mocks.StrictMock<IDataProvider>(),
Mocks.StrictMock<IDataProvider>(),
Mocks.StrictMock<IDataProvider>()
};
using (Mocks.Record())
{
IDataItem badItem = Mocks.StrictMock<IDataItem>();
Expect.Call(badItem.GetValue(bindings[0])).Throw(new InvalidOperationException("Test exception"));
Expect.Call(providers[0].GetItems(bindings, true)).Return(new IDataItem[] {
new ScalarDataItem<int>(1, null, false),
new ScalarDataItem<int>(2, null, true),
new ScalarDataItem<int>(1, null, false),
new ScalarDataItem<int>(3, null, false),
new ScalarDataItem<int>(6, null, false),
});
Expect.Call(providers[1].GetItems(bindings, true)).Return(new IDataItem[] {
new ScalarDataItem<int>(1, null, false),
new ScalarDataItem<int>(1, null, false),
badItem,
new ScalarDataItem<int>(2, null, true),
new ScalarDataItem<int>(6, null, false),
new ScalarDataItem<int>(1, null, false),
new ScalarDataItem<int>(4, null, false),
});
Expect.Call(providers[2].GetItems(bindings, true)).Return(new IDataItem[] {
new ScalarDataItem<int>(1, null, false),
new ScalarDataItem<int>(1, null, false),
new ScalarDataItem<int>(5, null, false),
new ScalarDataItem<int>(3, null, false),
new ScalarDataItem<int>(2, null, true)
});
}
using (Mocks.Playback())
{
List<IDataItem> items = new List<IDataItem>(IntersectionMergeStrategy.Instance.Merge(providers, bindings, true));
Assert.Count(3, items);
Assert.AreEqual(1, items[0].GetValue(bindings[0]));
Assert.IsFalse(items[0].IsDynamic);
Assert.AreEqual(1, items[1].GetValue(bindings[0]));
Assert.IsFalse(items[1].IsDynamic);
Assert.AreEqual(2, items[2].GetValue(bindings[0]));
Assert.IsTrue(items[2].IsDynamic);
}
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:58,代码来源:IntersectionMergeStrategyTest.cs
示例11: ScalarDataBinder
/// <summary>
/// Creates a scalar data binder.
/// </summary>
/// <param name="binding">The data binding.</param>
/// <param name="sourceName">The data source name to query, or an empty string if it is anonymous.</param>
public ScalarDataBinder(DataBinding binding, string sourceName)
{
if (binding == null)
throw new ArgumentNullException("binding");
if (sourceName == null)
throw new ArgumentNullException("sourceName");
this.binding = binding;
this.sourceName = sourceName;
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:15,代码来源:ScalarDataBinder.cs
示例12: HandlesDegenerateCaseWithZeroProviders
public void HandlesDegenerateCaseWithZeroProviders()
{
DataBinding[] bindings = new DataBinding[] {
new DataBinding(0, null)
};
IDataProvider[] providers = new IDataProvider[0];
List<IDataItem> items = new List<IDataItem>(IntersectionMergeStrategy.Instance.Merge(providers, bindings, true));
Assert.Count(0, items);
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:10,代码来源:IntersectionMergeStrategyTest.cs
示例13: ReplaceIndexCreatesANewInstanceWithTheNewIndex
public void ReplaceIndexCreatesANewInstanceWithTheNewIndex()
{
DataBinding oldBinding = new DataBinding(42, "path");
DataBinding newBinding = oldBinding.ReplaceIndex(23);
Assert.AreNotSame(oldBinding, newBinding);
Assert.AreEqual("path", newBinding.Path);
Assert.AreEqual(23, newBinding.Index);
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:10,代码来源:DataBindingTest.cs
示例14: CanBindImpl
/// <inheritdoc />
protected override bool CanBindImpl(DataBinding binding)
{
foreach (IDataSet dataSet in DataSets)
{
if (!dataSet.CanBind(binding))
return false;
}
return true;
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:11,代码来源:MergedDataSet.cs
示例15: JoinsItemsSequentiallyAndPadsWithNullsUntilExhausted
public void JoinsItemsSequentiallyAndPadsWithNullsUntilExhausted()
{
DataBinding[][] bindingsPerProvider = new DataBinding[][] {
new DataBinding[] { new DataBinding(0, null) },
new DataBinding[] { },
new DataBinding[] { new DataBinding(0, null) },
};
IDataProvider[] providers = new IDataProvider[] {
Mocks.StrictMock<IDataProvider>(),
Mocks.StrictMock<IDataProvider>(),
Mocks.StrictMock<IDataProvider>()
};
IDataItem[][] itemsPerProvider = new IDataItem[][] {
new IDataItem[] {
new ScalarDataItem<int>(1, null, true),
new ScalarDataItem<int>(2, null, false)
},
new IDataItem[] { },
new IDataItem[] {
new ScalarDataItem<int>(1, null, false),
new ScalarDataItem<int>(2, null, false),
new ScalarDataItem<int>(3, null, false)
}
};
using (Mocks.Record())
{
Expect.Call(providers[0].GetItems(bindingsPerProvider[0], true)).Return(itemsPerProvider[0]);
Expect.Call(providers[1].GetItems(bindingsPerProvider[1], true)).Return(itemsPerProvider[1]);
Expect.Call(providers[2].GetItems(bindingsPerProvider[2], true)).Return(itemsPerProvider[2]);
}
using (Mocks.Playback())
{
List<IList<IDataItem>> items = new List<IList<IDataItem>>(SequentialJoinStrategy.Instance.Join(providers, bindingsPerProvider, true));
Assert.Count(3, items);
Assert.AreSame(itemsPerProvider[0][0], items[0][0]);
Assert.AreSame(NullDataItem.Instance, items[0][1]);
Assert.AreSame(itemsPerProvider[2][0], items[0][2]);
Assert.AreSame(itemsPerProvider[0][1], items[1][0]);
Assert.AreSame(NullDataItem.Instance, items[1][1]);
Assert.AreSame(itemsPerProvider[2][1], items[1][2]);
Assert.AreSame(NullDataItem.Instance, items[2][0]);
Assert.AreSame(NullDataItem.Instance, items[2][1]);
Assert.AreSame(itemsPerProvider[2][2], items[2][2]);
}
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:52,代码来源:SequentialJoinStrategyTest.cs
示例16: GetValueCallsRowsGetValueWithTheBinding
public void GetValueCallsRowsGetValueWithTheBinding()
{
IDataItem item = Mocks.StrictMock<IDataItem>();
DataBinding binding = new DataBinding(0, null);
using (Mocks.Record())
{
Expect.Call(item.GetValue(binding)).Return(42);
}
using (Mocks.Playback())
{
BoundDataAccessor accessor = new BoundDataAccessor(binding);
Assert.AreEqual(42, accessor.GetValue(item));
}
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:17,代码来源:BoundDataAccessorTest.cs
示例17: EliminatesDuplicatesAndIncludesBadItems
public void EliminatesDuplicatesAndIncludesBadItems()
{
DataBinding[] bindings = new DataBinding[] {
new DataBinding(0, null)
};
IDataProvider[] providers = new IDataProvider[] {
Mocks.StrictMock<IDataProvider>(),
Mocks.StrictMock<IDataProvider>(),
Mocks.StrictMock<IDataProvider>()
};
using (Mocks.Record())
{
IDataItem badItem = Mocks.StrictMock<IDataItem>();
Expect.Call(badItem.GetValue(bindings[0])).Repeat.Twice().Throw(new InvalidOperationException("Test exception"));
Expect.Call(providers[0].GetItems(bindings, true)).Return(new IDataItem[] {
new ScalarDataItem<int>(1, null, true),
new ScalarDataItem<int>(1, null, true),
new ScalarDataItem<int>(2, null, false),
});
Expect.Call(providers[1].GetItems(bindings, true)).Return(EmptyArray<IDataItem>.Instance);
Expect.Call(providers[2].GetItems(bindings, true)).Return(new IDataItem[] {
badItem,
new ScalarDataItem<int>(3, null, true),
new ScalarDataItem<int>(2, null, true)
});
}
using (Mocks.Playback())
{
List<IDataItem> items = new List<IDataItem>(UnionMergeStrategy.Instance.Merge(providers, bindings, true));
Assert.Count(4, items);
Assert.AreEqual(1, items[0].GetValue(bindings[0]));
Assert.IsTrue(items[0].IsDynamic);
Assert.AreEqual(2, items[1].GetValue(bindings[0]));
Assert.IsFalse(items[1].IsDynamic);
Assert.Throws<InvalidOperationException>(delegate { items[2].GetValue(bindings[0]); });
Assert.AreEqual(3, items[3].GetValue(bindings[0]));
Assert.IsTrue(items[3].IsDynamic);
}
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:45,代码来源:UnionMergeStrategyTest.cs
示例18: RemoveCommandHandler
private void RemoveCommandHandler(DataBinding binding)
{
var view = binding.View;
if (view == null) return;
string viewTypeName = view.GetType().FullName;
switch (viewTypeName)
{
// TODO: Add cases here for specialized view types, as needed
default:
if (view is AbsSpinner) ((AdapterView)view).ItemSelected -= AdapterView_ItemSelected;
else if (view is AdapterView) ((AdapterView)view).ItemClick -= AdapterView_ItemClick;
else
{
var command = (RelayCommand)binding.ViewModelPropertyInfo.GetValue(viewModel);
if (command != null) command.CanExecuteChanged -= binding.Command_CanExecuteChanged;
view.Click -= View_Click;
}
break;
}
}
开发者ID:ameetmanit,项目名称:MvvmQuickCross,代码行数:20,代码来源:ViewDataBindings.UI.cs
示例19: AddCommandHandler
private void AddCommandHandler(DataBinding binding)
{
if (binding.ViewProperty == null || binding.ViewProperty.ContainingObject == null) return;
var view = binding.ViewProperty.ContainingObject;
string viewTypeName = view.GetType().FullName;
switch (viewTypeName)
{
// TODO: Add cases here for specialized view types, as needed
#if __DIALOG__
case "MonoTouch.Dialog.StringElement":
case "MonoTouch.Dialog.StyledStringElement":
((StringElement)view).Tapped += () => ExecuteCommand(binding);
break;
#endif
case "MonoTouch.UIKit.UIButton":
{
var button = (UIButton)view;
button.TouchUpInside += HandleTouchUpInside;
var command = (RelayCommand)binding.ViewModelPropertyInfo.GetValue(viewModel);
if (command != null)
{
command.CanExecuteChanged += binding.Command_CanExecuteChanged;
button.Enabled = command.IsEnabled;
}
}
break;
case "MonoTouch.UIKit.UIBarButtonItem":
{
var button = (UIBarButtonItem)view;
button.Clicked += (s, e) => ExecuteCommand(binding);
var command = (RelayCommand)binding.ViewModelPropertyInfo.GetValue(viewModel);
if (command != null)
{
command.CanExecuteChanged += binding.Command_CanExecuteChanged;
button.Enabled = command.IsEnabled;
}
}
break;
}
}
开发者ID:rvdplas,项目名称:QuickCross,代码行数:40,代码来源:ViewDataBindings.UI.cs
示例20: CombinesItemsIntoASingleSequence
public void CombinesItemsIntoASingleSequence()
{
DataBinding[] bindings = new DataBinding[] {
new DataBinding(0, null)
};
IDataProvider[] providers = new IDataProvider[] {
Mocks.StrictMock<IDataProvider>(),
Mocks.StrictMock<IDataProvider>(),
Mocks.StrictMock<IDataProvider>()
};
using (Mocks.Record())
{
Expect.Call(providers[0].GetItems(bindings, true)).Return(new IDataItem[] {
new ScalarDataItem<int>(1, null, false),
new ScalarDataItem<int>(2, null, false),
});
Expect.Call(providers[1].GetItems(bindings, true)).Return(EmptyArray<IDataItem>.Instance);
Expect.Call(providers[2].GetItems(bindings, true)).Return(new IDataItem[] {
new ScalarDataItem<int>(3, null, true),
});
}
using (Mocks.Playback())
{
List<IDataItem> items = new List<IDataItem>(ConcatenationMergeStrategy.Instance.Merge(providers, bindings, true));
Assert.Count(3, items);
Assert.AreEqual(1, items[0].GetValue(bindings[0]));
Assert.IsFalse(items[0].IsDynamic);
Assert.AreEqual(2, items[1].GetValue(bindings[0]));
Assert.IsFalse(items[1].IsDynamic);
Assert.AreEqual(3, items[2].GetValue(bindings[0]));
Assert.IsTrue(items[2].IsDynamic);
}
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:40,代码来源:ConcatenationMergeStrategyTest.cs
注:本文中的DataBinding类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论