当前位置: 首页>>代码示例>>C#>>正文


C# DataContext.AddOrUpdate方法代码示例

本文整理汇总了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);
        }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:11,代码来源:ValidatesOnExceptionsBehavior.cs

示例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;
 }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:72,代码来源:BindingParser.cs

示例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);
 }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:21,代码来源:ValidatesOnNotifyDataErrorsBehavior.cs

示例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;
        }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:34,代码来源:XamarinFormsBootstrapperBase.cs


注:本文中的DataContext.AddOrUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。