public void BuildCreateMethod(GeneratedType generatedType, DocumentMapping aggregateMapping) { var returnType = IsAsync ? typeof(ValueTask <>).MakeGenericType(AggregateType) : AggregateType; var args = new[] { new Argument(typeof(IEvent), "@event"), new Argument(typeof(IQuerySession), "session") }; if (IsAsync) { args = args.Concat(new[] { new Argument(typeof(CancellationToken), "cancellation") }).ToArray(); } var method = new GeneratedMethod(MethodName, returnType, args); method.AsyncMode = IsAsync ? AsyncMode.AsyncTask : AsyncMode.None; generatedType.AddMethod(method); var eventHandling = AddEventHandling(AggregateType, aggregateMapping, this); method.Frames.Add(eventHandling); method.Frames.Add(new DefaultAggregateConstruction(AggregateType, generatedType) { IfStyle = IfStyle.None }); }
public void BuildApplyMethod(GeneratedType generatedType, IDocumentMapping aggregateMapping) { var returnType = IsAsync ? typeof(ValueTask <>).MakeGenericType(AggregateType) : AggregateType; var args = new[] { new Argument(typeof(IEvent), "@event"), new Argument(AggregateType, "aggregate"), new Argument(typeof(IQuerySession), "session") }; if (IsAsync) { args = args.Concat(new[] { new Argument(typeof(CancellationToken), "cancellation") }).ToArray(); } var method = new GeneratedMethod(MethodName, returnType, args); generatedType.AddMethod(method); var eventHandling = AddEventHandling(AggregateType, aggregateMapping, this); method.Frames.Add(eventHandling); method.Frames.Code("return {0};", new Use(AggregateType)); }
public void WriteRouteMatchMethod(GeneratedType generatedType) { if (Route.Segments.OfType <RouteArgument>().Any()) { var method = new GeneratedMethod($"Matches{Route.VariableName}", typeof(bool), new Argument(typeof(string[]), "segments")); generatedType.AddMethod(method); method.Frames.Add(new RouteMatchFrame(Route)); } }