本文整理汇总了C#中IDataContext.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# IDataContext.Contains方法的具体用法?C# IDataContext.Contains怎么用?C# IDataContext.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataContext
的用法示例。
在下文中一共展示了IDataContext.Contains方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public virtual void Start(IDataContext context = null)
{
Initialize();
context = context.ToNonReadOnly();
if (!context.Contains(NavigationConstants.IsDialog))
context.Add(NavigationConstants.IsDialog, false);
var app = MvvmApplication.Current;
var viewModelType = app.GetStartViewModelType();
var mappingProvider = app.IocContainer.Get<IViewMappingProvider>();
IViewMappingItem mapping = mappingProvider.FindMappingForViewModel(viewModelType, context.GetData(NavigationConstants.ViewName), true);
if (typeof(Page).IsAssignableFrom(mapping.ViewType))
{
_rootWindow = CreateNavigationWindow();
var service = CreateNavigationService(_rootWindow);
app.IocContainer.BindToConstant(service);
}
app.IocContainer.Get<IViewModelPresenter>().DynamicPresenters.Add(this);
app.Start(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: Start
public virtual void Start(IDataContext context = null)
{
Initialize();
context = context.ToNonReadOnly();
if (!context.Contains(NavigationConstants.IsDialog))
context.Add(NavigationConstants.IsDialog, false);
var app = MvvmApplication.Current;
app.IocContainer.Get<IViewModelPresenter>().DynamicPresenters.Add(this);
app.Start(context);
}
示例4: CreateBuilder
public IBindingBuilder CreateBuilder(IDataContext context = null)
{
context = context.ToNonReadOnly();
if (!context.Contains(BindingBuilderConstants.BuildDelegate))
context.Add(BindingBuilderConstants.BuildDelegate, _buildDelegate);
return new BindingBuilder(context);
}
示例5: btnDelete_Click
private void btnDelete_Click(object sender, EventArgs e)
{
IList<Ocena> selItems = getDataGridViewUserControl()
.getSelectedItems<Ocena>();
if (selItems.Count != 1)
return;
Ocena ocena = selItems[0];
string msg = String.Format(
"Da li zelite da izbrisete ocenu za gimnasticara '{0}', za spravu '{1}'?",
ocena.Gimnasticar.ImeSrednjeImePrezime, Sprave.toString(ActiveSprava));
if (!MessageDialogs.queryConfirmation(msg, this.Text))
return;
Cursor.Current = Cursors.WaitCursor;
Cursor.Show();
try
{
try
{
DataAccessProviderFactory factory = new DataAccessProviderFactory();
dataContext = factory.GetDataContext();
dataContext.BeginTransaction();
dataContext.Delete(ocena);
IList<RezultatskoTakmicenje> rezTakmicenja = loadRezTakmicenja(ocena.Gimnasticar);
foreach (RezultatskoTakmicenje rezTak in rezTakmicenja)
{
if (deoTakKod == DeoTakmicenjaKod.Takmicenje1)
{
rezTak.Takmicenje1.ocenaDeleted(ocena, rezTak);
dataContext.Save(rezTak.Takmicenje1);
}
else if (deoTakKod == DeoTakmicenjaKod.Takmicenje2)
{
if (rezTak.Propozicije.OdvojenoTak2)
{
rezTak.Takmicenje2.ocenaDeleted(ocena, rezTak);
dataContext.Save(rezTak.Takmicenje2);
}
}
else if (deoTakKod == DeoTakmicenjaKod.Takmicenje3)
{
if (rezTak.Propozicije.OdvojenoTak3)
{
rezTak.Takmicenje3.ocenaDeleted(ocena, rezTak);
dataContext.Save(rezTak.Takmicenje3);
}
}
else if (deoTakKod == DeoTakmicenjaKod.Takmicenje4)
{
if (rezTak.Propozicije.OdvojenoTak4)
{
rezTak.Takmicenje4.ocenaDeleted(ocena, rezTak);
dataContext.Save(rezTak.Takmicenje4);
}
}
}
foreach (RezultatskoTakmicenje rezTak in rezTakmicenja)
{
if (deoTakKod == DeoTakmicenjaKod.Takmicenje1)
{
foreach (GimnasticarUcesnik g in rezTak.Takmicenje1.Gimnasticari)
dataContext.Evict(g);
}
else if (deoTakKod == DeoTakmicenjaKod.Takmicenje2)
{
foreach (UcesnikTakmicenja2 u in rezTak.Takmicenje2.Ucesnici)
{
if (dataContext.Contains(u.Gimnasticar))
dataContext.Evict(u.Gimnasticar);
dataContext.Evict(u);
}
}
else if (deoTakKod == DeoTakmicenjaKod.Takmicenje3)
{
foreach (UcesnikTakmicenja3 u in rezTak.Takmicenje3.Ucesnici)
{
if (dataContext.Contains(u.Gimnasticar))
dataContext.Evict(u.Gimnasticar);
dataContext.Evict(u);
}
}
}
dataContext.Commit();
}
catch (Exception ex)
{
if (dataContext != null && dataContext.IsInTransaction)
dataContext.Rollback();
MessageDialogs.showError(Strings.getFullDatabaseAccessExceptionMessage(ex), this.Text);
Close();
return;
}
finally
{
if (dataContext != null)
//.........这里部分代码省略.........