本文整理汇总了C#中IDataContext类的典型用法代码示例。如果您正苦于以下问题:C# IDataContext类的具体用法?C# IDataContext怎么用?C# IDataContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDataContext类属于命名空间,在下文中一共展示了IDataContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplicationApiController
protected ApplicationApiController(
IDataContext dataContext,
Func<int> getUserId)
{
this.DataContext = dataContext;
this.UserId = getUserId();
}
示例2: Execute
public void Execute(IDataContext context, DelegateExecute nextExecute)
{
var textControl = context.GetData(DataConstants.TEXT_CONTROL);
GC.KeepAlive(textControl);
DateTime lastInvocation, utcNow = DateTime.UtcNow;
lock (syncLock)
{
lastInvocation = this.lastLocateInvocation;
this.lastLocateInvocation = utcNow;
}
const int doubleKeyPressDelay = 500;
if (utcNow.Subtract(lastInvocation).TotalMilliseconds < doubleKeyPressDelay)
{
var locateFileAction = actionManager.TryGetAction(LocateFileAction.Id) as IExecutableAction;
if (locateFileAction != null)
{
locateFileAction.Execute(context);
return;
}
}
if (lastUnderlyingActionUpdate)
{
nextExecute();
}
}
示例3: SetErrors
/// <summary>
/// Sets errors for binding target.
/// </summary>
/// <param name="target">The binding target object.</param>
/// <param name="errors">The collection of errors</param>
/// <param name="context">The specified context, if any.</param>
protected override sealed void SetErrors(object target, IList<object> errors, IDataContext context)
{
base.SetErrors(target, errors, context);
var control = target as Control;
if (control == null)
return;
Control rootControl = PlatformExtensions.GetRootControl(control);
if (rootControl == null)
return;
ErrorProvider errorProvider = GetErrorProviderInternal(rootControl);
if (errorProvider == null)
return;
var oldProvider = ServiceProvider
.AttachedValueProvider
.GetValue<ErrorProvider>(target, ErrorProviderName, false);
if (!ReferenceEquals(oldProvider, errorProvider))
{
if (oldProvider != null)
{
oldProvider.SetError(control, null);
TryDispose(oldProvider);
}
ServiceProvider.AttachedValueProvider.SetValue(control, ErrorProviderName, errorProvider);
if (errorProvider.Tag == null)
errorProvider.Tag = 1;
else if (errorProvider.Tag is int)
errorProvider.Tag = (int)errorProvider.Tag + 1;
}
SetErrors(control, errorProvider, errors, context);
}
示例4: Handle
public void Handle(ref string bindingExpression, IDataContext context)
{
foreach (var replaceKeyword in ReplaceKeywords)
bindingExpression = bindingExpression.Replace(replaceKeyword.Key, replaceKeyword.Value);
if (!bindingExpression.Contains("$\"") && !bindingExpression.Contains("$'"))
return;
Dictionary<string, string> dict = null;
InterpolatedStringTokenizer.SetSource(bindingExpression);
while (InterpolatedStringTokenizer.Token != TokenType.Eof)
{
int start;
int end;
var exp = ParseInterpolatedString(InterpolatedStringTokenizer, out start, out end);
if (exp != null)
{
if (dict == null)
dict = new Dictionary<string, string>();
dict[bindingExpression.Substring(start, end - start)] = exp;
}
}
if (dict != null)
{
foreach (var s in dict)
{
if (s.Value != null)
bindingExpression = bindingExpression.Replace(s.Key, s.Value);
}
}
}
示例5: Compose
private void Compose(IDataContext value)
{
foreach(var child in transform)
{
var go = ((Transform)child).gameObject;
go.SetActive(false);
}
_composedDataContext = value;
if(value != null)
{
var name = value.GetType().Name;
foreach(var child in transform)
{
var go = ((Transform)child).gameObject;
if (go.name != name)
continue;
go.SetActive(true);
break;
}
}
BroadcastDataContextChange(_composedDataContext);
}
示例6: UnitOfWork
public UnitOfWork(IDataContext dataContext, IUnitOfWorkManager manager)
{
State = UnitOfWorkState.Active;
DataContext = dataContext;
Manager = manager;
Manager.Add(this);
}
示例7: Update
/// <summary>
/// Updates the property value.
/// </summary>
/// <param name="dataContext">
/// The data context.
/// </param>
/// <param name="target">
/// The target.
/// </param>
public void Update(IDataContext dataContext, object target)
{
if (target == null)
throw new ArgumentNullException("target");
Property.SetValue(target, ValueCalculator.GetValue(dataContext));
}
示例8: IsAvailable
public override bool IsAvailable(IDataContext context)
{
IList<ITypeMember> typeMembers;
ITypeElement ownerType;
var moveStaticMembersIsAvailable = IsAvailable(context, out typeMembers, out ownerType);
if (!moveStaticMembersIsAvailable) return false;
Methods = new List<IMethod>();
foreach (var typeMember in typeMembers) {
var method = typeMember != null ? typeMember as IMethod : null;
if (method == null) return false;
// Do a quick check to see if Extension Methods are allowed.
var methodDeclaration = method.GetDeclarations().FirstOrDefault();
if (methodDeclaration != null) {
var treeNode = methodDeclaration.CreateTreeElementPointer().GetTreeNode();
if (treeNode != null && !treeNode.IsVB9Supported()) return false;
}
if (!method.IsStatic || method.Parameters.None() || method.Parameters.First().Kind != ParameterKind.VALUE) return false;
if (method.IsExtensionMethod ^ Direction == WorkflowDirection.ExtensionToShared) return false;
Methods.Add(method);
}
return true;
}
示例9: GetOriginTypeElement
private static ITypeElement GetOriginTypeElement(IDataContext dataContext, DeclaredElementTypeUsageInfo initialTarget)
{
var data = dataContext.GetData(DataConstants.REFERENCES);
if (data == null) {
return null;
}
foreach (var current in data.OfType<IQualifiableReference>()) {
if (!Equals(current.Resolve().DeclaredElement, initialTarget)) {
continue;
}
var qualifierWithTypeElement = current.GetQualifier() as IQualifierWithTypeElement;
if (qualifierWithTypeElement == null) {
continue;
}
var qualifierTypeElement = qualifierWithTypeElement.GetQualifierTypeElement();
if (qualifierTypeElement != null) {
return qualifierTypeElement;
}
}
return null;
}
示例10: GetModel
public static EngineCodeMappingViewModel GetModel(IDataContext context)
{
return new EngineCodeMappingViewModel()
{
Configuration = context.ConfigurationSettings
};
}
示例11: IsAvailable
// Hides the menu item if it's not a Unity project
public override bool IsAvailable(IDataContext dataContext)
{
var project = dataContext.GetData(ProjectModelDataConstants.PROJECT);
if (project == null || !project.IsUnityProject())
return false;
return base.IsAvailable(dataContext);
}
示例12: MarketMappingViewModel
private static async Task<MarketMappingViewModel> GetFullAndPartialViewModelForMarketMapping
(
IDataContext context,
MarketMappingFilter filter
)
{
var baseModel = SharedModelBase.GetBaseModel(context);
var model = new MarketMappingViewModel()
{
PageIndex = filter.PageIndex.HasValue ? filter.PageIndex.Value : 1,
PageSize = filter.PageSize.HasValue ? filter.PageSize.Value : Int32.MaxValue,
Configuration = context.ConfigurationSettings,
CurrentUser = baseModel.CurrentUser,
CurrentVersion = baseModel.CurrentVersion
};
var marketMapping = await context.Market.GetFdpMarketMapping(filter);
var programmeFilter = new ProgrammeFilter()
{
ProgrammeId = marketMapping.ProgrammeId,
Gateway = marketMapping.Gateway,
Code = model.MarketMapping.Programme.VehicleName // In order to filter the gateways specific to the programme
};
HydrateModelWithCommonProperties(model, context, programmeFilter);
model.Gateways = context.Vehicle.ListGateways(programmeFilter);
if (!(marketMapping is EmptyFdpMarketMapping))
{
marketMapping.Programme = model.Programmes.FirstOrDefault(p => p.Id == marketMapping.ProgrammeId.GetValueOrDefault());
}
model.MarketMapping = marketMapping;
return model;
}
示例13: GenerateContent
protected override string GenerateContent(IDataContext context, string outputFolder)
{
var bound = context.GetComponent<ISettingsStore>().BindToContextTransient(ContextRange.ApplicationWide);
foreach (TemplateApplicability applicability in Enum.GetValues(typeof(TemplateApplicability)))
CreateXml(applicability, bound, outputFolder, GeneralHelpers.GetCurrentVersion(), context);
return "Code templates";
}
示例14: GetSessionId
private static string GetSessionId(IDataContext context)
{
UnitTestSession session = GetUnitTestSession(context);
if (session == null)
return null;
#if ! RESHARPER_50_OR_NEWER || RESHARPER_60_OR_NEWER
return session.ID;
#else
// HACK: Get the last RunId for correlation instead of the SessionId because the SessionId is
// not available to the task runner in R# 5.0 but the RunId is, so we use that for correlation.
// Unfortunately runs are transient so they are deleted after tests finish. However before that
// happens, the Update method will be called many times to update UI state so we should be able
// to catch the run in flight and save it for later.
//
// I have asked JetBrains to provide SessionId info to TaskRunners in a future release
// as it was done in R# 3.1. -- Jeff.
foreach (IUnitTestRun run in session.Runs)
{
string runId = run.ID;
LastRunIdCache[session.ID] = runId;
return runId;
}
string lastRunId;
LastRunIdCache.TryGetValue(session.ID, out lastRunId);
return lastRunId;
#endif
}
示例15: IsAvailable
public bool IsAvailable(IDataContext dataContext)
{
// todo make this resolvable also via the AllTypes... line
var invokedNode = dataContext.GetSelectedTreeNode<IExpression>();
return cachedRegistrations.Any(r => r.Registration.RegistrationElement.Children().Contains(invokedNode));
}