/// <summary> /// Initializes a new instance of the <see cref="BatchResultProcessor" /> class. /// </summary> /// <param name="field">The field.</param> /// <param name="sourceItems">The source items.</param> /// <param name="origin">The origin.</param> public BatchResultProcessor(IGraphField field, IEnumerable <GraphDataItem> sourceItems, SourceOrigin origin) { _origin = origin; _field = Validation.ThrowIfNullOrReturn(field, nameof(field)); _sourceItems = Validation.ThrowIfNullOrReturn(sourceItems, nameof(sourceItems)); this.Messages = new GraphMessageCollection(); }
public CloneVacancyCommand(Guid cloneVacancyId, Guid newVacancyId, VacancyUser user, SourceOrigin sourceOrigin) { IdOfVacancyToClone = cloneVacancyId; NewVacancyId = newVacancyId; User = user; SourceOrigin = sourceOrigin; }
public void SourceOrigin_Empty_PropertyCheck() { var origin = new SourceOrigin(); Assert.AreEqual(SourcePath.None, origin.Path); Assert.AreEqual(SourceLocation.None, origin.Location); }
/// <summary> /// Initializes a new instance of the <see cref="GraphExecutionException" /> class. /// </summary> /// <param name="message">The message.</param> /// <param name="origin">The origin.</param> /// <param name="innerException">The exception that is the cause of the current exception if any.</param> public GraphExecutionException( string message, SourceOrigin origin = null, Exception innerException = null) : base(message, innerException) { this.Origin = origin; }
/// <summary> /// Adds the trace message to the collection. /// </summary> /// <param name="message">The body text for this new message.</param> /// <param name="errorCode">An optional error code to apply to the message..</param> /// <param name="origin">The origin in the source text where this message was generated.</param> /// <param name="exceptionThrown">An exception that may have been thrown and caused this message to be created.</param> /// <returns>IGraphExecutionMessage.</returns> public IGraphMessage Trace( string message, string errorCode = "", SourceOrigin origin = null, Exception exceptionThrown = null) { return(this.Add(GraphMessageSeverity.Trace, message, errorCode, origin, exceptionThrown)); }
public async Task <Guid> CloneVacancyAsync(Guid vacancyId, VacancyUser user, SourceOrigin sourceOrigin) { var newVacancyId = GenerateVacancyId(); var command = new CloneVacancyCommand(cloneVacancyId: vacancyId, newVacancyId: newVacancyId, user: user, sourceOrigin: sourceOrigin); await _messaging.SendCommandAsync(command); return(newVacancyId); }
public CreateProviderOwnedVacancyCommand(Guid vacancyId, SourceOrigin origin, long ukprn, string employerAccountId, VacancyUser user, UserType userType, string title) { VacancyId = vacancyId; Origin = origin; Ukprn = ukprn; EmployerAccountId = employerAccountId; User = user; UserType = userType; Title = title; }
public CloneVacancyCommand( Guid cloneVacancyId, Guid newVacancyId, VacancyUser user, SourceOrigin sourceOrigin, DateTime startDate, DateTime closingDate) { IdOfVacancyToClone = cloneVacancyId; NewVacancyId = newVacancyId; User = user; SourceOrigin = sourceOrigin; StartDate = startDate; ClosingDate = closingDate; }
/// <summary> /// Initializes a new instance of the <see cref="GraphFieldRequest" /> class. /// </summary> /// <param name="invocationContext">The invocation context that defines how hte field /// should be processed according to the query plan.</param> /// <param name="dataSource">The data source containing the the source input data to the field as well as /// the graph items referenced by said input data.</param> /// <param name="origin">The location in the source query where this field request was generated.</param> /// <param name="items">A collection of meta data items to carry with this request.</param> public GraphFieldRequest( IGraphFieldInvocationContext invocationContext, GraphFieldDataSource dataSource, SourceOrigin origin, MetaDataCollection items = null) { this.Id = Guid.NewGuid().ToString("N"); this.InvocationContext = Validation.ThrowIfNullOrReturn(invocationContext, nameof(invocationContext)); this.Origin = Validation.ThrowIfNullOrReturn(origin, nameof(origin)); this.Items = items ?? new MetaDataCollection(); this.DataSource = dataSource; }
public void SourceOrigin_NoPath_PropertyCheck() { var location = new SourceLocation(5, 2, 1); var origin = new SourceOrigin(location); Assert.AreEqual(SourcePath.None, origin.Path); Assert.AreEqual(location, origin.Location); // use location string if path is empty Assert.AreEqual(location.ToString(), origin.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="GraphDirectiveRequest" /> class. /// </summary> /// <param name="targetDirective">The target directive.</param> /// <param name="location">The location.</param> /// <param name="origin">The origin.</param> /// <param name="requestMetaData">The request meta data.</param> public GraphDirectiveRequest( IDirectiveGraphType targetDirective, DirectiveLocation location, SourceOrigin origin, MetaDataCollection requestMetaData = null) { this.Id = Guid.NewGuid().ToString("N"); this.Directive = Validation.ThrowIfNullOrReturn(targetDirective, nameof(targetDirective)); this.LifeCycle = DirectiveLifeCycle.BeforeResolution; this.DirectiveLocation = location; this.Origin = origin ?? SourceOrigin.None; this.Items = requestMetaData ?? new MetaDataCollection(); }
public void SourceOrigin_NoLocation_PropertyCheck() { var path = new SourcePath(); path.AddFieldName("topField"); path.AddFieldName("middleField"); path.AddArrayIndex(0); var origin = new SourceOrigin(path); Assert.AreEqual(path, origin.Path); Assert.AreEqual(SourceLocation.None, origin.Location); }
public async Task <Guid> CloneVacancyAsync( Guid vacancyId, VacancyUser user, SourceOrigin sourceOrigin, DateTime startDate, DateTime closingDate) { var newVacancyId = GenerateVacancyId(); var command = new CloneVacancyCommand(vacancyId, newVacancyId, user, sourceOrigin, startDate, closingDate); await _messaging.SendCommandAsync(command); await AssignVacancyNumber(newVacancyId); return(newVacancyId); }
/// <summary> /// Initializes a new instance of the <see cref="GraphExecutionMessage" /> class. /// </summary> /// <param name="severity">The severity level of this message.</param> /// <param name="message">The message text body.</param> /// <param name="code">The code assigned to this message, if any.</param> /// <param name="origin">The origin in the source text where this message was generated.</param> /// <param name="exception">The underlying exception that was thrown by the runtime, if any.</param> public GraphExecutionMessage( GraphMessageSeverity severity, string message, string code = null, SourceOrigin origin = null, Exception exception = null) { this.Origin = origin ?? SourceOrigin.None; this.Code = code?.Trim() ?? "-unknown-"; this.Message = message?.Trim(); this.Severity = severity; this.Exception = exception; this.TimeStamp = DateTimeOffset.UtcNow; this.MetaData = new Dictionary <string, object>(); }
/// <summary> /// Adds the message to the collection. /// </summary> /// <param name="severity">The severity of this new message.</param> /// <param name="message">The body text for this new message.</param> /// <param name="errorCode">An optional error code to apply to the message..</param> /// <param name="origin">The origin in the source text, if any, that this message relates to.</param> /// <param name="exceptionThrown">An exception that may have been thrown and caused this message to be created.</param> /// <returns>IGraphExecutionMessage.</returns> public IGraphMessage Add( GraphMessageSeverity severity, string message, string errorCode = "", SourceOrigin origin = null, Exception exceptionThrown = null) { var graphMessage = new GraphExecutionMessage( severity, message, errorCode, origin, exceptionThrown); return(this.Add(graphMessage)); }
/// <summary> /// Creates a graph message from the given rule and message specifics in a common manner. /// </summary> /// <param name="validationRule">The validation rule that is being broken.</param> /// <param name="messageText">The context sensitive message text.</param> /// <param name="messageOrigin">The origin location where this message is generated, if any.</param> /// <param name="exception">The exception generated with extended details, if any.</param> /// <returns>IGraphMessage.</returns> internal static IGraphMessage FromValidationRule( IValidationRule validationRule, string messageText, SourceOrigin messageOrigin = null, Exception exception = null) { var graphMessage = new GraphExecutionMessage( GraphMessageSeverity.Critical, messageText, validationRule.ErrorCode, messageOrigin, exception); graphMessage.MetaData.Add(Constants.Messaging.REFERENCE_RULE_NUMBER, validationRule.RuleNumber); graphMessage.MetaData.Add(Constants.Messaging.REFERENCE_RULE_URL, validationRule.ReferenceUrl); return(graphMessage); }
public void SourceOrigin_WithBothParts_PropertyCheck() { var path = new SourcePath(); path.AddFieldName("topField"); path.AddFieldName("middleField"); path.AddArrayIndex(0); var location = new SourceLocation(5, 2, 1); var origin = new SourceOrigin(location, path); Assert.AreEqual(path, origin.Path); Assert.AreEqual(location, origin.Location); // prefer path over source text when available Assert.AreEqual(path.ToString(), origin.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="FieldInvocationContext" /> class. /// </summary> /// <param name="expectedSourceType">Expected type of the source.</param> /// <param name="name">The name to apply to this data set once resolution is complete.</param> /// <param name="field">The field.</param> /// <param name="origin">The origin, in the source text, that this context was generated from.</param> /// <param name="directives">The directives parsed from a query document that are to be executed as part of this context.</param> public FieldInvocationContext( Type expectedSourceType, string name, IGraphField field, SourceOrigin origin, IEnumerable <IDirectiveInvocationContext> directives = null) { this.Name = Validation.ThrowIfNullWhiteSpaceOrReturn(name, nameof(name)); this.Field = Validation.ThrowIfNullOrReturn(field, nameof(field)); this.ExpectedSourceType = expectedSourceType; this.Origin = origin; this.ChildContexts = new FieldInvocationContextCollection(); this.Arguments = new InputArgumentCollection(); var list = new List <IDirectiveInvocationContext>(); if (directives != null) { list.AddRange(directives); } this.Directives = list; }
private LongListMultiSelector GetSelectorBySourceOrigin(SourceOrigin source) { LongListMultiSelector selector = null; switch (source) { case SourceOrigin.BingToday: selector = BingTodayPictureSelector; break; case SourceOrigin.NasaToday: selector = NasaTodayPictureSelector; break; case SourceOrigin.Search: selector = WebPictureSelector; break; default: selector = PhonePictureSelector; break; } return(selector); }
private void AddGameObject(GameObject gameObject) { var source = SourceTransform(); var origin = new SourceOrigin(gameObject); sourceOrigins.Add(origin); #if UNITY_EDITOR Undo.SetTransformParent(gameObject.transform, source, "Creating Mesh"); #else gameObject.transform.parent = source; #endif }
/// <summary> /// Using the child context being invoked, this method creates the execution contexts in a manner /// that is expected by the invocation context be that 1 per each item, or 1 for a collective set of items being batched. /// </summary> /// <param name="context">The context.</param> /// <param name="childInvocationContext">The child invocation context.</param> /// <param name="sourceItemsToInclude">The source items to include.</param> /// <returns>IEnumerable<GraphFieldExecutionContext>.</returns> private IEnumerable <GraphFieldExecutionContext> CreateChildExecutionContexts( GraphFieldExecutionContext context, IGraphFieldInvocationContext childInvocationContext, IEnumerable <GraphDataItem> sourceItemsToInclude) { if (childInvocationContext.Field.Mode == FieldResolutionMode.PerSourceItem) { foreach (var sourceItem in sourceItemsToInclude) { var child = sourceItem.AddChildField(childInvocationContext); var dataSource = new GraphFieldDataSource(sourceItem.ResultData, child.Origin.Path, child); var request = new GraphFieldRequest(childInvocationContext, dataSource, child.Origin, context.Request.Items); yield return(new GraphFieldExecutionContext( context, request, context.VariableData, context.DefaultFieldSources)); } } else if (childInvocationContext.Field.Mode == FieldResolutionMode.Batch) { // remove any potential indexers from the path to this batch operation // in general this will be acted on a collection of items, attempt to remove // the first found instance of an indexer in the chain to indicate the path to the batch // // items may be declared as: Top.Parent[0].BatchField, Top.Parent[1].BatchField // alter the canonical path to be: Top.Parent.BatchField var fieldPath = sourceItemsToInclude.First().Origin.Path.Clone(); while (fieldPath.IsIndexedItem) { fieldPath = fieldPath.MakeParent(); } fieldPath.AddFieldName(childInvocationContext.Field.Name); var batchOrigin = new SourceOrigin(context.Request.Origin.Location, fieldPath); // create a list to house the raw source data being passed for the batch // this is the IEnumerable<T> required as an input to any batch resolver var sourceArgumentType = childInvocationContext.Field.Arguments.SourceDataArgument?.ObjectType ?? typeof(object); var sourceListType = typeof(List <>).MakeGenericType(sourceArgumentType); var sourceDataList = InstanceFactory.CreateInstance(sourceListType) as IList; // create a list of all the GraphDataItems representing the field // being resolved per input item var sourceItemList = new List <GraphDataItem>(); foreach (var item in sourceItemsToInclude) { var childField = item.AddChildField(childInvocationContext); sourceDataList.Add(item.ResultData); sourceItemList.Add(childField); } var dataSource = new GraphFieldDataSource( sourceDataList, fieldPath, sourceItemList); var request = new GraphFieldRequest(childInvocationContext, dataSource, batchOrigin, context.Request.Items); yield return(new GraphFieldExecutionContext( context, request, context.VariableData, context.DefaultFieldSources)); } else { throw new ArgumentOutOfRangeException( nameof(childInvocationContext.Field.Mode), $"The execution mode for field '{childInvocationContext.Field.Route.Path}' cannot be processed " + $"by {nameof(ProcessChildFieldsMiddleware<TSchema>)}. (Mode: {childInvocationContext.Field.Mode.ToString()})"); } }
/// <summary> /// Adds a custom origin to the field request instead of using <see cref="SourceOrigin.None"/>. /// </summary> /// <param name="origin">The origin.</param> /// <returns>MockFieldExecutionContext.</returns> public FieldContextBuilder AddOrigin(SourceOrigin origin) { _mockRequest.Setup(x => x.Origin).Returns(origin); _mockInvocationContext.Setup(x => x.Origin).Returns(origin); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="GraphDirectiveExecutionContext"/> class. /// </summary> /// <param name="seenAtLocation">The seen at location.</param> /// <param name="graphType">Type of the graph.</param> /// <param name="origin">The origin.</param> public GraphDirectiveExecutionContext(DirectiveLocation seenAtLocation, IDirectiveGraphType graphType, SourceOrigin origin) { this.Location = seenAtLocation; this.Directive = graphType; this.Origin = origin; this.Arguments = new InputArgumentCollection(); }