Generate Microsoft C# source files from any Node.js projects just using a simple and well-structured language document object model API.
This package is designed for usage with TypeScript and provides extensive typings for the C# document object model.
Install with npm:
npm install @hexarc/csharp-dom
Using with node.js (ES6 syntax):
import * as CSharpDom from "@hexarc/csharp-dom";
Or using the CommonJS module syntax:
const CSharpDom = require("@hexarc/csharp-dom");
import * as fs from "fs";
import * as CSharpDom from "@hexarc/csharp-dom";
const codeUnit: Hexarc.CSharpDom.CodeUnit = {
name: "Point2D.cs",
namespaces: [{
path: ["Hexarc", "Geometry"],
types: [{
kind: "class",
access: "public",
modifier: "sealed",
name: "Point2D",
members: [{
kind: "property",
access: "public",
type: { namespace: "System", name: "Single" },
name: "X"
}, {
kind: "property",
access: "public",
type: { namespace: "System", name: "Single" },
name: "Y"
}]
}]
}]
};
fs.writeFileSync(codeUnit.name, CSharpDom.emit(codeUnit));
namespace Hexarc.Geometry
{
public sealed class Point2D
{
public System.Single X { get; set; }
public System.Single Y { get; set; }
}
}
import * as fs from "fs";
import * as CSharpDom from "@hexarc/csharp-dom";
const codeUnit: Hexarc.CSharpDom.CodeUnit = {
name: "enum.cs",
namespaces: [{
path: ["Hexarc", "Flags"],
types: [{
kind: "enum",
access: "public",
name: "Direction",
members: [{
name: "Up"
}, {
name: "Down"
}, {
name: "Left"
}, {
name: "Right"
}]
}]
}]
};
fs.writeFileSync(codeUnit.name, CSharpDom.emit(codeUnit));
namespace Hexarc.Flags
{
public enum Direction
{
Up,
Down,
Left,
Right
}
}