blob: d97b23db0046e4f6d3c68876b494c2e1ab931765 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package org.zwobble.couscous.backends.csharp;
import org.zwobble.couscous.Backend;
import org.zwobble.couscous.ast.TypeNode;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import static com.google.common.collect.Iterables.transform;
public class CsharpBackend implements Backend {
private final Path outputFilePath;
private final String namespace;
public CsharpBackend(Path outputFilePath, String namespace) {
this.outputFilePath = outputFilePath;
this.namespace = namespace;
}
@Override
public void compile(List<TypeNode> classes) throws IOException {
outputFilePath.getParent().toFile().mkdirs();
Files.write(
outputFilePath,
transform(
CsharpCodeGenerator.generateCode(classes, namespace),
CsharpSerializer::serialize));
}
}
|