Skip to content

Commit 64b01ac

Browse files
committed
更新初始化器文档
1 parent e9d80ea commit 64b01ac

File tree

6 files changed

+194
-4
lines changed

6 files changed

+194
-4
lines changed

src/docs/compile/002-SmartMode-Full.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,31 @@ title: "2.1 智能编译模式 - 实现程序集"
1313
3. 智能编译。
1414

1515
## 预热案例
16+
## 链式预热
17+
18+
从 V9 版本起,Natasha 支持链式预热:
19+
20+
```cs
21+
NatashaManagement
22+
//获取链式构造器
23+
.GetInitializer()
24+
//使用引用程序集中的命名空间
25+
.WithRefUsing()
26+
//使用引用程序集中的元数据
27+
.WithRefReference()
28+
//使用内存中的命名空间
29+
.WithMemoryUsing()
30+
//使用内存中的元数据
31+
.WithMemoryReference()
32+
//使用文件来持久化缓存 命名空间
33+
.WithFileUsingCache()
34+
//过滤哪些元数据是不能用的,被排除的
35+
.WithExcludeReferences((asm, asmStr) => { return false; })
36+
//注册域构造器
37+
.Preheating<NatashaDomainCreator>();
38+
```
39+
40+
如果不指定相关 API ,预热将跳过此行为,例如只写 WithXXXReference 不写 using 相关的 API, 那么 Natasha 预热时将只对元数据进行操作,不会缓存 using code. 这样做的好处是实现了高度定制化,按需预热。
1641

1742
### 普通预热
1843
1. 泛型预热方法将自动创建 编译域创建者 单例。
@@ -22,13 +47,35 @@ title: "2.1 智能编译模式 - 实现程序集"
2247
```cs
2348
//注册编译域并预热方法
2449
NatashaManagement.Preheating<NatashaDomainCreator>(true, true);
50+
//或者 V9 版本
51+
NatashaManagement
52+
//获取链式构造器
53+
.GetInitializer()
54+
//使用引用程序集中的命名空间
55+
.WithMemoryUsing()
56+
//使用内存中的元数据
57+
.WithMemoryReference()
58+
//注册域构造器
59+
.Preheating<NatashaDomainCreator>();
2560
```
2661

2762
### Using缓存预热
28-
第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
63+
指定第三个参数,第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
2964
```cs
3065
//注册编译域并预热方法
3166
NatashaManagement.Preheating<NatashaDomainCreator>(true, truetrue);
67+
//或者 V9 版本
68+
NatashaManagement
69+
//获取链式构造器
70+
.GetInitializer()
71+
//使用引用程序集中的命名空间
72+
.WithMemoryUsing()
73+
//使用内存中的元数据
74+
.WithMemoryReference()
75+
//使用文件来持久化缓存 命名空间
76+
.WithFileUsingCache()
77+
//注册域构造器
78+
.Preheating<NatashaDomainCreator>();
3279
```
3380

3481
### 分开预热

src/docs/compile/002-SmartMode-Ref.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@ title: "2.2 智能编译模式 - 引用程序集"
1616

1717
## 预热案例
1818

19+
### 链式预热
20+
21+
从 V9 版本起,Natasha 支持链式预热:
22+
23+
```cs
24+
NatashaManagement
25+
//获取链式构造器
26+
.GetInitializer()
27+
//使用引用程序集中的命名空间
28+
.WithRefUsing()
29+
//使用引用程序集中的元数据
30+
.WithRefReference()
31+
//使用内存中的命名空间
32+
.WithMemoryUsing()
33+
//使用内存中的元数据
34+
.WithMemoryReference()
35+
//使用文件来持久化缓存 命名空间
36+
.WithFileUsingCache()
37+
//过滤哪些元数据是不能用的,被排除的
38+
.WithExcludeReferences((asm, asmStr) => { return false; })
39+
//注册域构造器
40+
.Preheating<NatashaDomainCreator>();
41+
```
42+
43+
如果不指定相关 API ,预热将跳过此行为,例如只写 WithXXXReference 不写 using 相关的 API, 那么 Natasha 预热时将只对元数据进行操作,不会缓存 using code. 这样做的好处是实现了高度定制化,按需预热。
44+
1945
### 普通预热
2046
1. 泛型预热方法将自动创建 编译域创建者 单例。
2147
2. 传入 false 参数以达到禁用运行时程序集的作用,Natasha 将会选择引用程序集预热。
@@ -24,13 +50,35 @@ title: "2.2 智能编译模式 - 引用程序集"
2450
```cs
2551
//注册编译域并预热方法
2652
NatashaManagement.Preheating<NatashaDomainCreator>(false, false);
53+
//或 V9 版本
54+
NatashaManagement
55+
//获取链式构造器
56+
.GetInitializer()
57+
//使用引用程序集中的命名空间
58+
.WithRefUsing()
59+
//使用引用程序集中的元数据
60+
.WithRefReference()
61+
//注册域构造器
62+
.Preheating<NatashaDomainCreator>();
2763
```
2864

2965
### Using缓存预热
3066
第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
3167
```cs
3268
//注册编译域并预热方法
3369
NatashaManagement.Preheating<NatashaDomainCreator>(false, falsetrue);
70+
//或 V9 版本
71+
NatashaManagement
72+
//获取链式构造器
73+
.GetInitializer()
74+
//使用引用程序集中的命名空间
75+
.WithRefUsing()
76+
//使用引用程序集中的元数据
77+
.WithRefReference()
78+
//使用文件来持久化缓存 命名空间
79+
.WithFileUsingCache()
80+
//注册域构造器
81+
.Preheating<NatashaDomainCreator>();
3482
```
3583

3684
### 分开预热

src/docs/compile/006-Advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,5 @@ builder.WithoutPrivateMembers();
123123
builder
124124
.OutputAsRefAssembly();
125125
.WithFileOutput()
126-
.WithoutInjectToDomain();
126+
.CompileWithoutAssembly();
127127
```

src/i18n/zh-Hans/docusaurus-plugin-content-docs/current/compile/002-SmartMode-Full.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,31 @@ title: "2.1 智能编译模式 - 实现程序集"
1313
3. 智能编译。
1414

1515
## 预热案例
16+
## 链式预热
17+
18+
从 V9 版本起,Natasha 支持链式预热:
19+
20+
```cs
21+
NatashaManagement
22+
//获取链式构造器
23+
.GetInitializer()
24+
//使用引用程序集中的命名空间
25+
.WithRefUsing()
26+
//使用引用程序集中的元数据
27+
.WithRefReference()
28+
//使用内存中的命名空间
29+
.WithMemoryUsing()
30+
//使用内存中的元数据
31+
.WithMemoryReference()
32+
//使用文件来持久化缓存 命名空间
33+
.WithFileUsingCache()
34+
//过滤哪些元数据是不能用的,被排除的
35+
.WithExcludeReferences((asm, asmStr) => { return false; })
36+
//注册域构造器
37+
.Preheating<NatashaDomainCreator>();
38+
```
39+
40+
如果不指定相关 API ,预热将跳过此行为,例如只写 WithXXXReference 不写 using 相关的 API, 那么 Natasha 预热时将只对元数据进行操作,不会缓存 using code. 这样做的好处是实现了高度定制化,按需预热。
1641

1742
### 普通预热
1843
1. 泛型预热方法将自动创建 编译域创建者 单例。
@@ -22,13 +47,35 @@ title: "2.1 智能编译模式 - 实现程序集"
2247
```cs
2348
//注册编译域并预热方法
2449
NatashaManagement.Preheating<NatashaDomainCreator>(true, true);
50+
//或者 V9 版本
51+
NatashaManagement
52+
//获取链式构造器
53+
.GetInitializer()
54+
//使用引用程序集中的命名空间
55+
.WithMemoryUsing()
56+
//使用内存中的元数据
57+
.WithMemoryReference()
58+
//注册域构造器
59+
.Preheating<NatashaDomainCreator>();
2560
```
2661

2762
### Using缓存预热
28-
第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
63+
指定第三个参数,第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
2964
```cs
3065
//注册编译域并预热方法
3166
NatashaManagement.Preheating<NatashaDomainCreator>(true, truetrue);
67+
//或者 V9 版本
68+
NatashaManagement
69+
//获取链式构造器
70+
.GetInitializer()
71+
//使用引用程序集中的命名空间
72+
.WithMemoryUsing()
73+
//使用内存中的元数据
74+
.WithMemoryReference()
75+
//使用文件来持久化缓存 命名空间
76+
.WithFileUsingCache()
77+
//注册域构造器
78+
.Preheating<NatashaDomainCreator>();
3279
```
3380

3481
### 分开预热

src/i18n/zh-Hans/docusaurus-plugin-content-docs/current/compile/002-SmartMode-Ref.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@ title: "2.2 智能编译模式 - 引用程序集"
1616

1717
## 预热案例
1818

19+
### 链式预热
20+
21+
从 V9 版本起,Natasha 支持链式预热:
22+
23+
```cs
24+
NatashaManagement
25+
//获取链式构造器
26+
.GetInitializer()
27+
//使用引用程序集中的命名空间
28+
.WithRefUsing()
29+
//使用引用程序集中的元数据
30+
.WithRefReference()
31+
//使用内存中的命名空间
32+
.WithMemoryUsing()
33+
//使用内存中的元数据
34+
.WithMemoryReference()
35+
//使用文件来持久化缓存 命名空间
36+
.WithFileUsingCache()
37+
//过滤哪些元数据是不能用的,被排除的
38+
.WithExcludeReferences((asm, asmStr) => { return false; })
39+
//注册域构造器
40+
.Preheating<NatashaDomainCreator>();
41+
```
42+
43+
如果不指定相关 API ,预热将跳过此行为,例如只写 WithXXXReference 不写 using 相关的 API, 那么 Natasha 预热时将只对元数据进行操作,不会缓存 using code. 这样做的好处是实现了高度定制化,按需预热。
44+
1945
### 普通预热
2046
1. 泛型预热方法将自动创建 编译域创建者 单例。
2147
2. 传入 false 参数以达到禁用运行时程序集的作用,Natasha 将会选择引用程序集预热。
@@ -24,13 +50,35 @@ title: "2.2 智能编译模式 - 引用程序集"
2450
```cs
2551
//注册编译域并预热方法
2652
NatashaManagement.Preheating<NatashaDomainCreator>(false, false);
53+
//或 V9 版本
54+
NatashaManagement
55+
//获取链式构造器
56+
.GetInitializer()
57+
//使用引用程序集中的命名空间
58+
.WithRefUsing()
59+
//使用引用程序集中的元数据
60+
.WithRefReference()
61+
//注册域构造器
62+
.Preheating<NatashaDomainCreator>();
2763
```
2864

2965
### Using缓存预热
3066
第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
3167
```cs
3268
//注册编译域并预热方法
3369
NatashaManagement.Preheating<NatashaDomainCreator>(false, falsetrue);
70+
//或 V9 版本
71+
NatashaManagement
72+
//获取链式构造器
73+
.GetInitializer()
74+
//使用引用程序集中的命名空间
75+
.WithRefUsing()
76+
//使用引用程序集中的元数据
77+
.WithRefReference()
78+
//使用文件来持久化缓存 命名空间
79+
.WithFileUsingCache()
80+
//注册域构造器
81+
.Preheating<NatashaDomainCreator>();
3482
```
3583

3684
### 分开预热

src/i18n/zh-Hans/docusaurus-plugin-content-docs/current/compile/006-Advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,5 @@ builder.WithoutPrivateMembers();
123123
builder
124124
.OutputAsRefAssembly();
125125
.WithFileOutput()
126-
.WithoutInjectToDomain();
126+
.CompileWithoutAssembly();
127127
```

0 commit comments

Comments
 (0)