public async Task Invoke(HttpContext httpContext, IContextData svc) { var email = httpContext.User.FindFirstValue(ClaimTypes.NameIdentifier); svc.CurrentUser = new Person(1, "lhar", "gil"); await _next(httpContext); }
public string GetItemValue(ContextItem item, bool onlyChanges, int coupon) { IContextData context = Access <IContextData>(); if (coupon == -1) { coupon = _ContextManager.MostRecentContextCoupon; } if (context != null) { Subject s = new Subject(item.Subject); object data = null; s.Items.Add(item); data = context.GetItemValues(s.ToItemNameArray(), onlyChanges, coupon); if (data != null && data.GetType() == typeof(object[])) { object[] info = (object[])data; if (info.Length == 2) { return(info[1].ToString()); } } } return(string.Empty); }
public async Task <BinaryComponent> GetBinaryComponentAsync(ContentNamespace ns, int publicationId, string url, string customMetaFilter, IContextData contextData, CancellationToken cancellationToken = default(CancellationToken)) => (await _client.ExecuteAsync <ContentQuery>( GraphQLRequests.BinaryComponent(ns, publicationId, url, customMetaFilter, contextData, GlobalContextDataInternal), cancellationToken).ConfigureAwait(false)).TypedResponseData.BinaryComponent;
public DefaultMessageConverter(JsonSerializer jsonSerializer, IContextData <MessageContext> contextData) { jsonSerializer.ContractResolver = new CamelCasePropertyNamesContractResolver(); _jsonSerializer = jsonSerializer; _contextData = contextData; }
public PublicationConnection GetPublications(ContentNamespace ns, IPagination pagination, InputPublicationFilter filter, string customMetaFilter, IContextData contextData) => _client.Execute <ContentQuery>(GraphQLRequests.Publications(ns, pagination, filter, customMetaFilter, contextData, GlobalContextDataInternal)).TypedResponseData.Publications;
public BinaryComponent GetBinaryComponent(ContentNamespace ns, int publicationId, string url, string customMetaFilter, IContextData contextData) => _client.Execute <ContentQuery>(GraphQLRequests.BinaryComponent(ns, publicationId, url, customMetaFilter, contextData, GlobalContextDataInternal)).TypedResponseData.BinaryComponent;
public ItemConnection ExecuteItemQuery(InputItemFilter filter, InputSortParam sort, IPagination pagination, string customMetaFilter, ContentIncludeMode contentIncludeMode, bool includeContainerItems, IContextData contextData) => _client.Execute <ContentQuery>(GraphQLRequests.ExecuteItemQuery(filter, sort, pagination, customMetaFilter, contentIncludeMode, includeContainerItems, contextData, GlobalContextDataInternal)).TypedResponseData.Items;
public DefaultMessageConverter(JsonSerializer jsonSerializer, IContextData<MessageContext> contextData) { jsonSerializer.ContractResolver = new CamelCasePropertyNamesContractResolver(); _jsonSerializer = jsonSerializer; _contextData = contextData; }
public Page GetPage(ContentNamespace ns, int publicationId, string url, string customMetaFilter, ContentIncludeMode contentIncludeMode, IContextData contextData) => _client.Execute <ContentQuery>( GraphQLRequests.Page(ns, publicationId, url, customMetaFilter, contentIncludeMode, contextData, GlobalContextDataInternal)) .TypedResponseData.Page;
public bool IsSetting(string subject, string name, int coupon) { IContextData context = Access <IContextData>(); string user = string.Empty; if (context != null) { object data = context.GetItemNames(coupon); if (data != null && data.GetType() == typeof(string[]) && ((string[])data).Length > 0) { string[] names = (string[])data; data = null; foreach (string n in names) { ContextItem item = new ContextItem(n); if (item.Subject.ToLower() == subject.ToLower() && item.Name.ToLower() == name.ToLower()) { return(true); } } } } return(false); }
/// <summary> /// Retrieves the set of <see cref="EntityData"/> data objects for all the entities /// belonging to the specified context. /// </summary> /// <remarks> /// The primary purpose of this method is lazy loading. The view model will ask for /// these only when it needs them. It allows us to defer examining metadata until /// we absolutely need it, which could be a large performance win when multiple /// contexts are available. /// </remarks> /// <param name="contextData">The <see cref="ContextData"/> to use to locate /// the respective <see cref="BusinessLogicContext"/>.</param> /// <returns>The set of <see cref="EntityData"/> objects for the given context.</returns> public IEntityData[] GetEntityDataItemsForContext(IContextData contextData) { IBusinessLogicContext context = this._contexts[contextData.ID]; List <IBusinessLogicEntity> entities = (context == null) ? new List <IBusinessLogicEntity>() : context.Entities.ToList(); return(entities.Select <IBusinessLogicEntity, IEntityData>(ble => ble.EntityData).ToArray()); }
public static IGraphQLRequest ExecuteItemQuery(InputItemFilter filter, InputSortParam sort, IPagination pagination, string customMetaFilter, ContentIncludeMode contentIncludeMode, bool includeContainerItems, IContextData contextData, IContextData globaContextData) { QueryBuilder builder = new QueryBuilder().WithQueryResource("ItemQuery", false); // We only include the fragments that will be required based on the item types in the // input item filter if (filter.ItemTypes != null) { string fragmentList = filter.ItemTypes.Select(itemType => $"{Enum.GetName(typeof (ContentModel.FilterItemType), itemType).Capitialize()}Fields") .Aggregate(string.Empty, (current, fragment) => current + $"...{fragment}\n"); // Just a quick and easy way to replace markers in our queries with vars here. builder.ReplaceTag("fragmentList", fragmentList); builder.LoadFragments(); } return(builder.WithIncludeRegion("includeContainerItems", includeContainerItems). WithPagination(pagination). WithCustomMetaFilter(customMetaFilter). WithContentIncludeMode(contentIncludeMode). WithInputItemFilter(filter). WithInputSortParam(sort). WithContextData(contextData). WithContextData(globaContextData). WithConvertor(new ItemConvertor()). Build()); }
public static IGraphQLRequest BinaryComponent(CmUri cmUri, string customMetaFilter, IContextData contextData, IContextData globalContextData) => new QueryBuilder().WithQueryResource("BinaryComponentByCmUri", true).WithCmUri(cmUri) .WithCustomMetaFilter(customMetaFilter) .WithContextData(contextData) .WithContextData(globalContextData) .Build();
public async Task <Page> GetPageAsync(ContentNamespace ns, int publicationId, string url, string customMetaFilter, ContentIncludeMode contentIncludeMode, IContextData contextData, CancellationToken cancellationToken = default(CancellationToken)) => (await _client.ExecuteAsync <ContentQuery>( GraphQLRequests.Page(ns, publicationId, url, customMetaFilter, contentIncludeMode, contextData, GlobalContextDataInternal), cancellationToken).ConfigureAwait(false)) .TypedResponseData.Page;
public static IGraphQLRequest Page(CmUri cmUri, string customMetaFilter, ContentIncludeMode contentIncludeMode, IContextData contextData, IContextData globalContextData) => new QueryBuilder().WithQueryResource("PageByCmUri", true).WithCmUri(cmUri) .WithCustomMetaFilter(customMetaFilter) .WithContentIncludeMode(contentIncludeMode) .WithContextData(contextData) .WithContextData(globalContextData) .Build();
public GetBillsListRequestHandler(SplitThatBillContext splitThatBillContext, IMapper mapper, IContextData contextData) { _splitThatBillContext = splitThatBillContext; _mapper = mapper; _contextData = contextData; }
public SplitThatBillContext(DbContextOptions <SplitThatBillContext> options , IContextData contextData , IDateTimeManager dateTimeManager) : base(options) { _contextData = contextData; _dateTimeManager = dateTimeManager; }
/// <summary> /// Generates the source code for the metadata class for the given context. /// </summary> /// <param name="contextData">The <see cref="ContextData"/> to use to locate the appropriate <see cref="BusinessLogicContext"/>.</param> /// <param name="rootNamespace">The root namespace (VB).</param> /// <param name="optionalSuffix">If nonblank, the suffix to append to namespace and class names for testing</param> /// <returns>A value containing the generated source code and necessary references.</returns> public IGeneratedCode GenerateMetadataClasses(IContextData contextData, string rootNamespace, string optionalSuffix) { IBusinessLogicContext context = this._contexts.Single(c => c.ContextData.ID == contextData.ID); return((context) != null ? context.GenerateMetadataClasses(this.Language, rootNamespace, optionalSuffix) : new GeneratedCode(string.Empty, new string[0])); }
public HealthWiseDbContext(DbContextOptions <HealthWiseDbContext> options, IDateTimeManager dateTimeManager, IContextData contextData ) : base(options) { _dateTimeManager = dateTimeManager; _contextData = contextData; }
public bool IsMetadataGenerationRequired(IContextData contextData) { IBusinessLogicContext context = this._contexts.SingleOrDefault(c => c.ContextData.ID == contextData.ID); return((context) != null ? context.NeedToGenerateMetadataClasses : false); }
/// <summary> /// Initializes a new instance of the <see cref="ContextViewModel"/> class. /// </summary> /// <param name="businessLogicModel">The <see cref="BusinessLogicModel"/> in the other AppDomain with which to communicate.</param> /// <param name="contextData">The shared state with the corresponding <see cref="BusinessLogicContext"/> instance in the other AppDomain.</param> public ContextViewModel(IBusinessLogicModel businessLogicModel, IContextData contextData) { System.Diagnostics.Debug.Assert(businessLogicModel != null, "businessLogicModel cannot be null"); System.Diagnostics.Debug.Assert(contextData != null, "contextData cannot be null"); this._businessLogicModel = businessLogicModel; this._contextData = contextData; }
/// <summary> /// Generates source code for the specified context. /// </summary> /// <param name="contextData">The <see cref="ContextData"/> to use to locate the appropriate <see cref="BusinessLogicContext"/>.</param> /// <param name="className">The name of the class.</param> /// <param name="namespaceName">The namespace to use for the class.</param> /// <param name="rootNamespace">The root namespace (VB).</param> /// <returns>A value containing the generated source code and necessary references.</returns> public IGeneratedCode GenerateBusinessLogicClass(IContextData contextData, string className, string namespaceName, string rootNamespace) { IBusinessLogicContext context = this._contexts.SingleOrDefault(c => c.ContextData.ID == contextData.ID); return(context != null ? context.GenerateBusinessLogicClass(this.Language, className, namespaceName, rootNamespace) : new GeneratedCode()); }
public static IGraphQLRequest Publications(ContentNamespace ns, IPagination pagination, InputPublicationFilter filter, string customMetaFilter, IContextData contextData, IContextData globalContextData) => new QueryBuilder().WithQueryResource("Publications", true).WithNamespace(ns).WithPagination(pagination) .WithInputPublicationFilter(filter) .WithCustomMetaFilter(customMetaFilter) .WithContextData(contextData) .WithContextData(globalContextData) .Build();
public QueryBuilder WithContextClaim(ClaimValue claim) { if (_contextData == null) { _contextData = new ContextData(); } _contextData.ClaimValues.Add(claim); return(this); }
public static IGraphQLRequest Publication(ContentNamespace ns, int publicationId, string customMetaFilter, IContextData contextData, IContextData globalContextData) => new QueryBuilder().WithQueryResource("Publication", true) .WithNamespace(ns) .WithPublicationId(publicationId) .WithCustomMetaFilter(customMetaFilter) .WithContextData(contextData) .WithContextData(globalContextData) .Build();
public CreateBillRequestHandler(SplitThatBillContext splitThatBillContext, IMapper mapper, IContextData contextData, IExternalIdGenerator externalIdGenerator) { _splitThatBillContext = splitThatBillContext; _mapper = mapper; _contextData = contextData; _externalIdGenerator = externalIdGenerator; }
public ContextFactory(IContextData contextData) { this.contextData = contextData; IEnumerator <IModuleContextBuilder> cdEnum = contextData.GetEnumerator(); while (cdEnum.MoveNext()) { builders.Add(cdEnum.Current.Name, cdEnum.Current.Build); } }
public ModuleReferenceKeyBinder(ISerializableModuleIdManager idManager, ISerializableId <List <Tuple <string, int, int, byte[]> > > id, IContextData contextData, IContextManager contextManager) { _idManager = idManager; _id = id; _contextData = contextData; _contextManager = contextManager; }
public static IGraphQLRequest Sitemap(ContentNamespace ns, int publicationId, int descendantLevels, IContextData contextData, IContextData globalContextData) => new QueryBuilder().WithQueryResource("Sitemap", true) .WithNamespace(ns) .WithPublicationId(publicationId) .WithDescendantLevels(descendantLevels) .WithContextData(contextData) .WithContextData(globalContextData) .WithConvertor(new TaxonomyItemConvertor()) .Build();
public void Set(Subject subject) { try { IContextData data = Access <IContextData>(); bool noContinue = true; object reasons; string decision = "accept"; bool disconnect = false; int transaction; transaction = _ContextManager.StartContextChanges(_ParticipantCoupon); data.SetItemValues(_ParticipantCoupon, subject.ToItemNameArray(), subject.ToItemValueArray(), transaction); reasons = _ContextManager.EndContextChanges(transaction, ref noContinue); // // If any application responded that they cannot apply the change we need to display // a dialog that displays the reasons for the problems. // if ((reasons != null && ((string[])reasons).Length > 0) || noContinue) { ProblemDialog pd = new ProblemDialog((string[])reasons, noContinue); DialogResult result; result = pd.ShowDialog(); if (noContinue) { decision = "cancel"; } if (result == DialogResult.OK) { decision = "accept"; } else if (result == DialogResult.Cancel) { decision = "cancel"; } else { decision = "cancel"; disconnect = true; } } _ContextManager.PublishChangesDecision(transaction, decision); if (disconnect) { Leave(); } } catch (Exception e) { Messager.ShowError(null, e); } }
public async Task <ItemConnection> ExecuteItemQueryAsync(InputItemFilter filter, InputSortParam sort, IPagination pagination, string customMetaFilter, ContentIncludeMode contentIncludeMode, bool includeContainerItems, IContextData contextData, CancellationToken cancellationToken = default(CancellationToken)) => ( await _client.ExecuteAsync <ContentQuery>( GraphQLRequests.ExecuteItemQuery(filter, sort, pagination, customMetaFilter, contentIncludeMode, includeContainerItems, contextData, GlobalContextDataInternal) , cancellationToken).ConfigureAwait(false)).TypedResponseData.Items;
public WebDiagnosticsInspector(IExceptionProcessor exceptionProcessor, IAgentBroker broker, IContextData<MessageContext> contextData, ILoggerFactory loggerFactory) { _exceptionProcessor = exceptionProcessor; _broker = broker; _contextData = contextData; _logger = loggerFactory.CreateLogger<WebDiagnosticsInspector>(); _proxyAdapter = new ProxyAdapter(); AspNetOnCreated(); MvcOnCreated(); }
public GlimpseMiddleware(Func<IDictionary<string, object>, Task> innerNext, IServiceProvider globalServices, Func<IHttpContext, bool> shouldRun) { var typeActivator = globalServices.GetService<ITypeActivator>(); _innerNext = innerNext; _globalServices = globalServices; _runtime = typeActivator.CreateInstance<RequestRuntimeHost>(); _contextData = new ContextData<MessageContext>(); // TODO: Need to find a way/better place for var settings = new Settings(); if (shouldRun != null) { settings.ShouldProfile = context => shouldRun((HttpContext)context); } _settings = settings; }
public GlimpseMiddleware(RequestDelegate innerNext, IServiceProvider serviceProvider, Func<IHttpContext, bool> shouldRun) { _innerNext = innerNext; var typeActivator = serviceProvider.GetService<ITypeActivator>(); _runtime = typeActivator.CreateInstance<RequestRuntimeHost>(); _contextData = new ContextData<MessageContext>(); // TODO: Need to find a way/better place for var settings = new Settings(); if (shouldRun != null) { settings.ShouldProfile = context => shouldRun((HttpContext)context); } _settings = settings; }
public DefaultAgentBroker(IMessagePublisher messagePublisher, IMessageConverter messageConverter, IContextData<MessageContext> context) { _messagePublisher = messagePublisher; _messageConverter = messageConverter; _context = context; _onSenderThreadSubject = new Subject<AgentBrokerPayload>(); _offSenderThreadSubject = new Subject<AgentBrokerPayload>(); _offSenderThreadInternalSubject = new Subject<AgentBrokerPayload>(); _publisherInternalSubject = new Subject<AgentBrokerPayload>(); OnSenderThread = new AgentBrokerObservations(_onSenderThreadSubject); OffSenderThread = new AgentBrokerObservations(_offSenderThreadSubject); // ensure off-request data is observed onto a different thread _offSenderThreadInternalSubject.Subscribe(payload => Observable.Start(() => _offSenderThreadSubject.OnNext(payload), TaskPoolScheduler.Default)); _publisherInternalSubject.Subscribe(x => Observable.Start(() => PublishMessage(x), TaskPoolScheduler.Default)); }
/// <summary> /// Retrieves the set of <see cref="EntityData"/> data objects for all the entities /// belonging to the specified context. /// </summary> /// <remarks> /// The primary purpose of this method is lazy loading. The view model will ask for /// these only when it needs them. It allows us to defer examining metadata until /// we absolutely need it, which could be a large performance win when multiple /// contexts are available. /// </remarks> /// <param name="contextData">The <see cref="ContextData"/> to use to locate /// the respective <see cref="BusinessLogicContext"/>.</param> /// <returns>The set of <see cref="EntityData"/> objects for the given context.</returns> public IEntityData[] GetEntityDataItemsForContext(IContextData contextData) { IBusinessLogicContext context = this._contexts[contextData.ID]; List<IBusinessLogicEntity> entities = (context == null) ? new List<IBusinessLogicEntity>() : context.Entities.ToList(); return entities.Select<IBusinessLogicEntity, IEntityData>(ble => ble.EntityData).ToArray(); }
public IContextData[] ImportData(Dictionary<string, object> connectionParameters) { List<DSGeometry> geometryList = new List<DSGeometry>(); DSGeometry[] geometry = null; foreach (var param in connectionParameters) { switch (param.Key) { case "OBJ": geometry = DSSubDivisionMesh.ImportFromOBJ(Convert.ToString(param.Value)); break; case "SAT": geometry = DSGeometry.ImportFromSAT(Convert.ToString(param.Value)); break; default: if (param.Value.GetType().IsArray) { Array data = param.Value as Array; geometry = GeometryDataSerializer.CreateGeometryFromData(param.Key, data); } break; } if (null != geometry && geometry.Length > 0) geometryList.AddRange(geometry); } int nItems = geometryList.Count; if (nItems == 0) return null; IContextData[] contextData = new IContextData[nItems]; for (int i = 0; i < nItems; ++i) { contextData[i] = new GeometryData("ImportData", geometryList[i], this); } return contextData; }
public bool IsMetadataGenerationRequired(IContextData contextData) { IBusinessLogicContext context = this._contexts.SingleOrDefault(c => c.ContextData.ID == contextData.ID); return (context) != null ? context.NeedToGenerateMetadataClasses : false; }
/// <summary> /// Generates the source code for the metadata class for the given context. /// </summary> /// <param name="contextData">The <see cref="ContextData"/> to use to locate the appropriate <see cref="BusinessLogicContext"/>.</param> /// <param name="rootNamespace">The root namespace (VB).</param> /// <param name="optionalSuffix">If nonblank, the suffix to append to namespace and class names for testing</param> /// <returns>A value containing the generated source code and necessary references.</returns> public IGeneratedCode GenerateMetadataClasses(IContextData contextData, string rootNamespace, string optionalSuffix) { IBusinessLogicContext context = this._contexts.Single(c => c.ContextData.ID == contextData.ID); return (context) != null ? context.GenerateMetadataClasses(this.Language, rootNamespace, optionalSuffix) : new GeneratedCode(string.Empty, new string[0]); }
private AssociativeNode ContextDataMethodCallNode(IContextData data) { string appname = data.ContextProvider.Name; string connectionstring = data.Name; string varname = data.Name; // //Build a functioncall node for expression varname = ImportData(appname, connectionstring); var func = new ProtoCore.AST.AssociativeAST.IdentifierNode(); func.Value = func.Name = ProtoCore.DSASM.Constants.kImportData; var paramAppName = new ProtoCore.AST.AssociativeAST.StringNode(); paramAppName.value = appname; var paramConnectionString = new ProtoCore.AST.AssociativeAST.StringNode(); paramConnectionString.value = connectionstring; var funcCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode(); funcCall.Function = func; funcCall.Name = ProtoCore.DSASM.Constants.kImportData; funcCall.FormalArguments.Add(paramAppName); funcCall.FormalArguments.Add(paramConnectionString); var var = new ProtoCore.AST.AssociativeAST.IdentifierNode(); var.Name = var.Value = varname; var assignExpr = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(); assignExpr.LeftNode = var; assignExpr.Optr = ProtoCore.DSASM.Operator.assign; assignExpr.RightNode = funcCall; return assignExpr; }
public void AddData(IContextData item) { mData.Add(item.Name, item); }
public DefaultGlimpseContextAccessor(IContextData<MessageContext> context) { _context = context; }
Dictionary<string, object> IContextDataProvider.ExportData(IContextData[] data, string filePath) { throw new NotImplementedException(); }
internal ExpressionSet(IContextData associatedContext) { this.expressions = new List<IReadOnlyExpression>(); AssociatedContextMutable = associatedContext; }
public void Setup() { context = CreationUtilities.CreateContext(); }
public Expression(IContextData context) { this.owningContext = context; this.ComponentsHead = null; this.SubExpressions = null; }
protected virtual void Dispose(bool disposing) { if (disposing) { if (this.contextData != null) { this.contextData.Dispose(); this.contextData = null; } } }
/// <summary> /// Generates source code for the specified context. /// </summary> /// <param name="contextData">The <see cref="ContextData"/> to use to locate the appropriate <see cref="BusinessLogicContext"/>.</param> /// <param name="className">The name of the class.</param> /// <param name="namespaceName">The namespace to use for the class.</param> /// <param name="rootNamespace">The root namespace (VB).</param> /// <returns>A value containing the generated source code and necessary references.</returns> public IGeneratedCode GenerateBusinessLogicClass(IContextData contextData, string className, string namespaceName, string rootNamespace) { IBusinessLogicContext context = this._contexts.SingleOrDefault(c => c.ContextData.ID == contextData.ID); return context != null ? context.GenerateBusinessLogicClass(this.Language, className, namespaceName, rootNamespace) : new GeneratedCode(); }