-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
44 lines (42 loc) · 1.43 KB
/
Program.cs
File metadata and controls
44 lines (42 loc) · 1.43 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.IO;
using Scriban;
namespace cs
{
class Program
{
class ClassProperty
{
public string Name { get; set; }
public bool IsServerOnly { get; set; }
public string Type { get; set; }
}
class Model
{
public string Name { get; set; }
public ClassProperty[] Properties { get; set; }
}
static ClassProperty[] userProperties = {
new ClassProperty { Name = "Id", IsServerOnly = false, Type = "int" },
new ClassProperty { Name = "UserName", IsServerOnly = false, Type = "string" },
new ClassProperty { Name = "Email", IsServerOnly = false, Type = "string" },
new ClassProperty { Name = "PasswordHash", IsServerOnly = true, Type = "string" },
};
static Model user = new Model { Name = "User", Properties = userProperties };
static void Main(string[] args)
{
var fileName = "template.sbn";
var content = File.ReadAllText(fileName);
var template = Template.Parse(content, fileName);
var result = template.Render(new {
NameSpace = "CsExample",
Class = user
});
var path = @".\user.cs";
using (StreamWriter sw = File.CreateText(path))
{
sw.Write(result);
}
}
}
}