private static void EnsureBaseType(string baseTypeName, string writeTo, HandlebarsTemplateRenderer renderer, CommandLineDelegatedClassModel model, HashSet <FileInfo> codeFiles) { FileInfo baseTypeCodeFile = new FileInfo(Path.Combine(writeTo, $"{baseTypeName}.cs")); string baseTypeCode = renderer.Render("ProviderBaseClass", model.ProviderBaseClass); baseTypeCode.SafeWriteToFile(baseTypeCodeFile.FullName, true); codeFiles.Add(baseTypeCodeFile); }
private static void GenerateConcreteType(string writeTo, string concreteTypeName, HandlebarsTemplateRenderer renderer, ConcreteClassModel model, HashSet <FileInfo> codeFiles) { FileInfo concreteTypeCodeFile = new FileInfo(Path.Combine(writeTo, $"{concreteTypeName}.cs")); string concreteTypeCode = renderer.Render("ConcreteClass", model); concreteTypeCode.SafeWriteToFile(concreteTypeCodeFile.FullName, true); codeFiles.Add(concreteTypeCodeFile); }
private static void GenerateDelegator(string writeTo, DelegatorClassModel model, HandlebarsTemplateRenderer renderer, HashSet <FileInfo> codeFiles) { FileInfo delegatorTypeCodeFile = new FileInfo(Path.Combine(writeTo, $"{model.BaseTypeName}Delegator.cs")); string delegatorCode = renderer.Render("Delegator", model); delegatorCode.SafeWriteToFile(delegatorTypeCodeFile.FullName, true); codeFiles.Add(delegatorTypeCodeFile); }
public override void WriteSource(string writeSourceDir) { List <TypeModel> typeModels = new List <TypeModel>(); Parallel.ForEach(Types, type => { TypeModel typeModel = new TypeModel { Type = type, SchemaName = Config.SchemaName, ToNameSpace = Config.ToNameSpace }; typeModels.Add(typeModel); string code = HandlebarsTemplateRenderer.Render("GraphQLType", typeModel); string writeToFile = Path.Combine(writeSourceDir, $"{type.Name}Graph.cs"); code.SafeWriteToFile(writeToFile, true); }); SchemaModel schemaModel = new SchemaModel() { SchemaName = Config.SchemaName, DataTypes = typeModels.ToArray(), UsingStatements = GetUsingStatements(typeModels.Select(t => t.Type)), ToNameSpace = Config.ToNameSpace }; string contextCode = HandlebarsTemplateRenderer.Render("GraphQLQueryContext", schemaModel); contextCode.SafeWriteToFile(Path.Combine(writeSourceDir, $"{Config.SchemaName}.cs"), true); }