public ITimerFunctionOptionsBuilder <TCommand> Timer <TCommand>(string cronExpression) { TimerFunctionDefinition timerFunctionDefinition = new TimerFunctionDefinition(typeof(TCommand)) { CronExpression = cronExpression }; _functionDefinitions.Add(timerFunctionDefinition); return(new TimerFunctionOptionsBuilder <TCommand>(_connectionStringSettingNames, _functionBuilder, timerFunctionDefinition)); }
public void Compile(IReadOnlyCollection <AbstractFunctionDefinition> functionDefinitions, OpenApiOutputModel openApiOutputModel, string outputBinaryFolder, string outputNamespaceName) { HandlebarsHelperRegistration.RegisterHelpers(); foreach (AbstractFunctionDefinition functionDefinition in functionDefinitions) { string templateSource = _templateProvider.GetJsonTemplate(functionDefinition); Func <object, string> template = Handlebars.Compile(templateSource); functionDefinition.AssemblyName = $"{outputNamespaceName}.dll"; functionDefinition.FunctionClassTypeName = $"{functionDefinition.Namespace}.{functionDefinition.Name}"; string json = template(functionDefinition); WriteFunctionTemplate(outputBinaryFolder, functionDefinition.Name, json); if (functionDefinition is CosmosDbFunctionDefinition cosmosDbFunctionDefinition) { if (cosmosDbFunctionDefinition.TrackRemainingWork) { TimerFunctionDefinition cosmosMonitorDefinition = new TimerFunctionDefinition(functionDefinition.CommandType) { AssemblyName = cosmosDbFunctionDefinition.AssemblyName, CommandDeserializerType = null, CommandType = null, CronExpression = cosmosDbFunctionDefinition.RemainingWorkCronExpression, FunctionClassTypeName = $"{functionDefinition.Namespace}.Monitor{functionDefinition.Name}" }; string timerTemplateSource = _templateProvider.GetJsonTemplate(cosmosMonitorDefinition); Func <object, string> timerTemplate = Handlebars.Compile(timerTemplateSource); string timerJson = timerTemplate(cosmosMonitorDefinition); WriteFunctionTemplate(outputBinaryFolder, $"Monitor{functionDefinition.Name}", timerJson); } } } if (openApiOutputModel != null && openApiOutputModel.IsConfiguredForUserInterface) { string templateSource = _templateProvider.GetTemplate("swaggerui", "json"); Func <object, string> template = Handlebars.Compile(templateSource); string json = template(new { AssemblyName = $"{outputNamespaceName}.dll", Namespace = outputNamespaceName }); WriteFunctionTemplate(outputBinaryFolder, "OpenApiProvider", json); } }
public ITimerFunctionOptionsBuilder <TCommand> Timer <TCommand, TTimerCommandFactoryType>(string cronExpression) where TTimerCommandFactoryType : ITimerCommandFactory <TCommand> { TimerFunctionDefinition timerFunctionDefinition = new TimerFunctionDefinition(typeof(TCommand)) { CronExpression = cronExpression, TimerCommandFactoryType = typeof(TTimerCommandFactoryType), TimerCommandFactoryTypeName = typeof(TTimerCommandFactoryType).EvaluateType() }; _functionDefinitions.Add(timerFunctionDefinition); return(new TimerFunctionOptionsBuilder <TCommand>(_connectionStringSettingNames, _functionBuilder, timerFunctionDefinition)); }
public void Compile(IReadOnlyCollection <AbstractFunctionDefinition> functionDefinitions, OpenApiOutputModel openApiOutputModel, string outputBinaryFolder, string outputNamespaceName) { foreach (AbstractFunctionDefinition functionDefinition in functionDefinitions) { string templateSource = _templateProvider.GetJsonTemplate(functionDefinition); Func <object, string> template = Handlebars.Compile(templateSource); functionDefinition.AssemblyName = $"{outputNamespaceName}.dll"; functionDefinition.FunctionClassTypeName = $"{functionDefinition.Namespace}.{functionDefinition.Name}"; string json = template(functionDefinition); WriteFunctionTemplate(outputBinaryFolder, functionDefinition.Name, json); if (functionDefinition is CosmosDbFunctionDefinition cosmosDbFunctionDefinition) { if (cosmosDbFunctionDefinition.TrackRemainingWork) { TimerFunctionDefinition cosmosMonitorDefinition = new TimerFunctionDefinition(functionDefinition.CommandType) { AssemblyName = cosmosDbFunctionDefinition.AssemblyName, CommandDeserializerType = null, CommandType = null, CronExpression = cosmosDbFunctionDefinition.RemainingWorkCronExpression, FunctionClassTypeName = $"{functionDefinition.Namespace}.Monitor{functionDefinition.Name}" }; string timerTemplateSource = _templateProvider.GetJsonTemplate(cosmosMonitorDefinition); Func <object, string> timerTemplate = Handlebars.Compile(timerTemplateSource); string timerJson = timerTemplate(cosmosMonitorDefinition); WriteFunctionTemplate(outputBinaryFolder, $"Monitor{functionDefinition.Name}", timerJson); } } } if (openApiOutputModel != null && !string.IsNullOrWhiteSpace(openApiOutputModel.UserInterfaceRoute)) { string templateSource = _templateProvider.GetTemplate("swaggerui", "json"); Func <object, string> template = Handlebars.Compile(templateSource); string json = template(new { AssemblyFilename = $"{outputNamespaceName}.dll", Namespace = outputNamespaceName, OpenApiUserInterfaceRoute = openApiOutputModel.UserInterfaceRoute }); WriteFunctionTemplate(outputBinaryFolder, "OpenApiProvider", json); } if (openApiOutputModel != null && !string.IsNullOrWhiteSpace(openApiOutputModel.ReDocUserInterfaceRoute)) { string reDocTemplateSource = _templateProvider.GetTemplate("redocui", "json"); Func <object, string> reDocTemplate = Handlebars.Compile(reDocTemplateSource); string reDocJson = reDocTemplate(new { AssemblyFilename = $"{outputNamespaceName}.dll", Namespace = outputNamespaceName, ReDocUserInterfaceRoute = openApiOutputModel.ReDocUserInterfaceRoute }); WriteFunctionTemplate(outputBinaryFolder, "ReDocProvider", reDocJson); } { string templateSource = _templateProvider.GetTemplate("extensions", "json"); Func <object, string> template = Handlebars.Compile(templateSource); string json = template(new { AssemblyName = $"{outputNamespaceName}", Namespace = outputNamespaceName }); WriteExtensionsTemplate(outputBinaryFolder, json); } }