本文整理汇总了C#中DataContext.AddOrUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# DataContext.AddOrUpdate方法的具体用法?C# DataContext.AddOrUpdate怎么用?C# DataContext.AddOrUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataContext
的用法示例。
在下文中一共展示了DataContext.AddOrUpdate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Detach
public void Detach(IDataBinding binding)
{
binding.BindingUpdated -= BindingUpdatedDelegate;
var errorProvider = BindingServiceProvider.ErrorProvider;
if (errorProvider == null)
return;
var context = new DataContext(binding.Context);
context.AddOrUpdate(BindingConstants.ClearErrors, true);
SetErrors(errorProvider, binding, Empty.Array<object>(), context);
}
示例2: Parse
public IList<IDataContext> Parse(object target, string bindingExpression, IList<object> sources, IDataContext context)
{
Should.NotBeNull(bindingExpression, nameof(bindingExpression));
if (context == null)
context = DataContext.Empty;
KeyValuePair<KeyValuePair<string, int>, Action<IDataContext>[]>[] bindingValues;
lock (_cache)
{
if (!_cache.TryGetValue(bindingExpression, out bindingValues))
{
try
{
if (ReferenceEquals(context, DataContext.Empty))
context = _defaultContext;
context.AddOrUpdate(BindingBuilderConstants.Target, target);
_context = context;
_expression = Handle(bindingExpression, context);
_tokenizer = CreateTokenizer(Expression);
_memberVisitor.Context = context;
var value = ParseInternal()
.Select((pair, i) => new KeyValuePair<KeyValuePair<string, int>, Action<IDataContext>[]>(new KeyValuePair<string, int>(pair.Key, i), pair.Value))
.ToList();
value.Sort(MemberComparison);
bindingValues = value.ToArray();
if (!context.Contains(BindingBuilderConstants.NoCache))
_cache[bindingExpression] = bindingValues;
}
finally
{
if (ReferenceEquals(_defaultContext, context))
_defaultContext.Clear();
_tokenizer = null;
_expression = null;
_context = null;
_memberVisitor.Context = null;
}
}
}
var result = new IDataContext[bindingValues.Length];
if (sources != null && sources.Count > 0)
{
for (int i = 0; i < bindingValues.Length; i++)
{
var pair = bindingValues[i];
var dataContext = new DataContext(context);
dataContext.AddOrUpdate(BindingBuilderConstants.Target, target);
if (pair.Key.Value < sources.Count)
{
object src = sources[pair.Key.Value];
if (src != null)
dataContext.Add(BindingBuilderConstants.Source, src);
}
var actions = pair.Value;
for (int j = 0; j < actions.Length; j++)
actions[j].Invoke(dataContext);
result[i] = dataContext;
}
}
else
{
for (int i = 0; i < bindingValues.Length; i++)
{
var actions = bindingValues[i].Value;
var dataContext = new DataContext(context);
dataContext.AddOrUpdate(BindingBuilderConstants.Target, target);
for (int j = 0; j < actions.Length; j++)
actions[j].Invoke(dataContext);
result[i] = dataContext;
}
}
return result;
}
示例3: OnDetached
protected override void OnDetached()
{
EventHandler<IObserver, ValueChangedEventArgs> handler = OnBindingSourceValueChanged;
var accessor = Binding.SourceAccessor as ISingleBindingSourceAccessor;
if (accessor == null)
{
var sources = Binding.SourceAccessor.Sources;
for (int index = 0; index < sources.Count; index++)
sources[index].ValueChanged -= handler;
}
else
accessor.Source.ValueChanged -= handler;
UpdateSources(true);
lock (_subscribers)
{
// Ensure that all concurrent adds have completed.
}
var context = new DataContext(Binding.Context);
context.AddOrUpdate(BindingErrorProviderBase.ClearErrorsConstant, true);
UpdateErrors(Empty.Array<object>(), context);
}
示例4: Start
/// <summary>
/// Starts the current bootstrapper.
/// </summary>
public virtual Page Start(bool wrapToNavigationPage = true)
{
if (Current != null && !ReferenceEquals(Current, this))
return Current.Start(wrapToNavigationPage);
InitializationContext = new DataContext(InitializationContext);
InitializationContext.AddOrUpdate(WrapToNavigationPageConstant, wrapToNavigationPage);
if (_mainViewModel == null || _mainViewModel.IsDisposed)
{
Initialize();
Type viewModelType = GetMainViewModelType();
_mainViewModel = CreateMainViewModel(viewModelType);
}
var view = (Page)ViewManager.GetOrCreateView(_mainViewModel, true, new DataContext(InitializationContext));
NavigationPage page = view as NavigationPage ?? CreateNavigationPage(view);
if (page == null)
return view;
INavigationService navigationService;
if (!IocContainer.TryGet(out navigationService))
{
navigationService = CreateNavigationService();
IocContainer.BindToConstant(navigationService);
}
//Activating navigation provider
INavigationProvider provider;
IocContainer.TryGet(out provider);
navigationService.UpdateRootPage(page);
return page;
}