Skip to content

C# class

A blueprint that creates a C# class together with its interface. File names and type names use PascalCase, the namespace is entered by hand.

blueprintor.config.js
module.exports = {
blueprints: [
{
title: "C# class",
variables: [
{ key: "name", prompt: "Class name" },
{ key: "ns", prompt: "Namespace (e.g. MyApp.Services)" },
],
snippets: {
contract: `
namespace {ns.raw};
public interface I{name.pascal}
{
void Run();
}
`,
implementation: `
namespace {ns.raw};
public class {name.pascal} : I{name.pascal}
{
public void Run()
{
}
}
`,
},
structure: {
files: [
{ name: "I{name.pascal}.cs", snippet: "contract" },
{ name: "{name.pascal}.cs", snippet: "implementation" },
],
},
},
],
};
  1. Right-click the folder where the class should live (for example src/MyApp/Services) and choose Run Blueprintor….

  2. Select C# class.

  3. Enter order service as the class name, then MyApp.Services as the namespace.

  • DirectoryServices
    • IOrderService.cs
    • OrderService.cs
namespace MyApp.Services;
public interface IOrderService
{
void Run();
}