use of com.google.api.codegen.viewmodel.SnippetsFileView in project toolkit by googleapis.
the class CSharpGapicSnippetsTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, csharpCommonTransformer.createTypeTable(namer.getExamplePackageName()), namer, new CSharpFeatureConfig());
csharpCommonTransformer.addCommonImports(context);
context.getImportTypeTable().saveNicknameFor("Google.Protobuf.Bytestring");
context.getImportTypeTable().saveNicknameFor("System.Linq.__import__");
SnippetsFileView snippets = generateSnippets(context);
surfaceDocs.add(snippets);
}
return surfaceDocs;
}
use of com.google.api.codegen.viewmodel.SnippetsFileView in project toolkit by googleapis.
the class CSharpGapicSnippetsTransformer method generateSnippets.
private SnippetsFileView generateSnippets(GapicInterfaceContext context) {
SurfaceNamer namer = context.getNamer();
String name = namer.getApiSnippetsClassName(context.getInterfaceConfig());
SnippetsFileView.Builder snippetsBuilder = SnippetsFileView.newBuilder();
snippetsBuilder.templateFileName(SNIPPETS_TEMPLATE_FILENAME);
String outputPath = pathMapper.getOutputPath(context.getInterface().getFullName(), context.getProductConfig());
snippetsBuilder.outputPath(outputPath + File.separator + name.replace("Generated", "") + ".g.cs");
snippetsBuilder.name(name);
snippetsBuilder.snippetMethods(generateMethods(context));
// must be done as the last step to catch all imports
snippetsBuilder.fileHeader(fileHeaderTransformer.generateFileHeader(context));
return snippetsBuilder.build();
}
Aggregations