Skip to content

Commit 8a37f83

Browse files
committed
添加ps脚本构建工程,自动生成目录
1 parent 2d6950c commit 8a37f83

16 files changed

+589
-83
lines changed

articles/CubeCore/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 魔方core版介绍
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 魔方中级教程

articles/CubeCore/中级教程/自定义高级查询.md

Whitespace-only changes.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 入门教程

articles/CubeCore/入门教程/运行.md

Whitespace-only changes.

articles/CubeCore/魔方core.md

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# 魔方core说明
2+
3+
## 菜单注册
4+
5+
### 区域使用AreaBaseX区域特性
6+
7+
- 自定义一个继承AreaBaseX的区域特性类,命名为“区域名”+“Area”
8+
- 继承构造函数base(areaName)
9+
- 定义的新区域特性要声明一个静态构造函数,调用RegisterArea静态方法
10+
- 示例
11+
12+
```csharp
13+
/// <summary>权限管理区域注册</summary>
14+
[DisplayName("系统管理")]
15+
public class AdminArea : AreaBaseX
16+
{
17+
public static string AreaName => nameof(AdminArea).TrimEnd("Area");
18+
19+
/// <inheritdoc />
20+
public AdminArea() : base(AreaName)
21+
{
22+
23+
}
24+
25+
static AdminArea()
26+
{
27+
RegisterArea<AdminArea>();
28+
}
29+
}
30+
```
31+
32+
- 如果不使用AreaBaseX区域特性路由,添加权限特性EntityAuthorizeAttribute,会自动添加此菜单
33+
34+
- 在区域控制器加上上面区域特性类
35+
36+
```csharp
37+
[AdminArea]
38+
public class UserController : EntityController<UserX>
39+
{
40+
41+
}
42+
```
43+
44+
### 控制器设置
45+
46+
- 如果控制器继承自魔方的功能控制器,那么会默认菜单相关选项
47+
- 如果需要自定义,则需要继承自`ControllerBaseX`
48+
- 重载`ScanActionMenu`方法,将菜单设置为可见`menu.Visible = true`
49+
- 声明一个静态变量设置菜单顺序`protected static Int32 MenuOrder { get; set; } = 100;`
50+
- 示例
51+
52+
```csharp
53+
[ApiArea]
54+
[DisplayName("SwaggerApi")]
55+
[Description("SwaggerApi")]
56+
public class SwaggerController : ControllerBaseX
57+
{
58+
59+
protected static Int32 MenuOrder { get; set; } = 100;
60+
61+
protected override IDictionary<MethodInfo, int> ScanActionMenu(IMenu menu)
62+
{
63+
// 设置显示名
64+
if (menu.DisplayName.IsNullOrEmpty())
65+
{
66+
menu.DisplayName = typeof(SwaggerController).GetCustomAttribute<DisplayNameAttribute>().DisplayName;
67+
menu.Visible = true;
68+
}
69+
70+
var dic = base.ScanActionMenu(menu);
71+
72+
return dic;
73+
}
74+
75+
// GET: Swagger
76+
[EntityAuthorize(PermissionFlags.Detail)]
77+
public ActionResult Index()
78+
{
79+
return View();
80+
}
81+
}
82+
```
83+
84+
或者
85+
86+
```csharp
87+
[ApiArea]
88+
public class HomeController : EntityController<UserX>
89+
{
90+
public override ActionResult Index(Pager p = null)
91+
{
92+
return View();
93+
}
94+
}
95+
```
96+
97+
## 视图
98+
99+
### 覆盖优先级
100+
101+
- 如果项目添加并引用Razor类库,那么它的优先级仅次于项目自身的视图
102+
- 其次,要引用nuget包里面的视图或者直接引用一个视图dll,需要手动进行注册,否则不会被出现在系统的查找范围
103+
- 可以同时存在多个视图资源,通过这个优先级选择对应视图,请查看下面更多说明
104+
- 魔方的视图结构请[查看这里](查看这里还什么也没有)
105+
106+
### 注册方法
107+
108+
- 可通过`typeof(Areas_Admin_Views_Index_Index).Assembly.FullName`这样子的名称获得视图所在程序集名称,注册方法如下
109+
110+
```csharp
111+
services.AddCustomApplicationParts(asmNaneList =>
112+
{
113+
asmNaneList.Add(typeof(Areas_Admin_Views_Index_Index).Assembly.FullName);
114+
});
115+
```
116+
117+
- 如果你想进行模块化开发,加载多个包含控制器的程序集,也是使用上面的方法进行注册
118+
- 但请注意控制名不要重复,否则你需要在对[路由命名空间优先级](这部分还没有说明)进行设置
119+
120+
### 更多说明
121+
122+
- 所有编译之后的视图程序集,生成的类名和命名空间都是一样的,所以如果同时引用多个含有视图的nuget包,编译器会`typeof(Areas_Admin_Views_Index_Index)`在这里报错
123+
- 那为什么Razor类库和项目本身都存在同样名字的视图,又不会报错呢?因为它们都还是源代码,还没编译啊。
124+
- core mvc 加载项目本身的控制器和视图的方法`ApplicationPartManager.PopulateDefaultParts`是内部的,不能调用,里面会根据引入的外部控制器所在程序集(比如你的项目引用了A程序集),寻找所有依赖于A程序集的程序集(比如A程序集对应的`A.Views.dll`),一起加载进系统成为系统的一部分。魔方提供`AddCustomApplicationParts`拓展方法自定义加载程序集,即使`A.Views.dll`依赖于A,你也可以选择不加载`A.Views.dll`,通过自己实现自己视图来呈现页面,给你更多的选择!

articles/build-toc.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
. ../build/build-toc.ps1 $PSScriptRoot

articles/toc-temp.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# [介绍](index.md)
2+
3+
# Agent
4+
## [Readme](Agent/Readme.MD)
5+
6+
# Api
7+
## [Readme](Api/Readme.MD)
8+
9+
# Cube
10+
## [Readme](Cube/Readme.MD)
11+
12+
# [CubeCore](CubeCore/index.md)
13+
## 中级教程
14+
### [自定义高级查询](CubeCore/中级教程/自定义高级查询.md)
15+
## 入门教程
16+
### [运行](CubeCore/入门教程/运行.md)
17+
## [魔方core](CubeCore/魔方core.md)
18+
19+
# [DotNetCore](DotNetCore/index.md)
20+
## [netcore_centos](DotNetCore/netcore_centos.md)
21+
22+
# Mobile
23+
## [Readme](Mobile/Readme.MD)
24+
25+
# Net
26+
## [Readme](Net/Readme.MD)
27+
## [新生命网络库客户端用法](Net/新生命网络库客户端用法.md)
28+
## [新生命网络库比较典型的简单用法](Net/新生命网络库比较典型的简单用法.md)
29+
30+
# Reflect
31+
## [Readme](Reflect/Readme.MD)
32+
33+
# Security
34+
## [Readme](Security/Readme.MD)
35+
36+
# Serialization
37+
## [Readme](Serialization/Readme.MD)
38+
39+
# Thread
40+
## [Readme](Thread/Readme.MD)
41+
42+
# XCode
43+
## [EntityCache](XCode/EntityCache.MD)
44+
## [ExtendProperty](XCode/ExtendProperty.MD)
45+
## [Get-Start](XCode/Get-Start.MD)
46+
## [Migration](XCode/Migration.MD)
47+
## [Model](XCode/Model.MD)
48+
## [Normal](XCode/Normal.MD)
49+
## [Readme](XCode/Readme.MD)
50+
## [Search](XCode/Search.MD)
51+
## [SingleCache](XCode/SingleCache.MD)
52+
53+
# XCoder
54+
## [Readme](XCoder/Readme.MD)
55+
56+
# XScript
57+
## [Readme](XScript/Readme.MD)
58+
59+
# XTemplate
60+
## [Readme](XTemplate/Readme.MD)

articles/toc.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# [介绍](index.md)
2+
3+
# Agent
4+
## [Readme](Agent/Readme.MD)
5+
6+
# Api
7+
## [Readme](Api/Readme.MD)
8+
9+
# Cube
10+
## [Readme](Cube/Readme.MD)
11+
12+
# [CubeCore](CubeCore/index.md)
13+
## 中级教程
14+
### [自定义高级查询](CubeCore/中级教程/自定义高级查询.md)
15+
## 入门教程
16+
### [运行](CubeCore/入门教程/运行.md)
17+
## [魔方core](CubeCore/魔方core.md)
18+
19+
# [DotNetCore](DotNetCore/index.md)
20+
## [netcore_centos](DotNetCore/netcore_centos.md)
21+
22+
# Mobile
23+
## [Readme](Mobile/Readme.MD)
24+
25+
# Net
26+
## [Readme](Net/Readme.MD)
27+
## [新生命网络库客户端用法](Net/新生命网络库客户端用法.md)
28+
## [新生命网络库比较典型的简单用法](Net/新生命网络库比较典型的简单用法.md)
29+
30+
# Reflect
31+
## [Readme](Reflect/Readme.MD)
32+
33+
# Security
34+
## [Readme](Security/Readme.MD)
35+
36+
# Serialization
37+
## [Readme](Serialization/Readme.MD)
38+
39+
# Thread
40+
## [Readme](Thread/Readme.MD)
41+
42+
# XCode
43+
## [EntityCache](XCode/EntityCache.MD)
44+
## [ExtendProperty](XCode/ExtendProperty.MD)
45+
## [Get-Start](XCode/Get-Start.MD)
46+
## [Migration](XCode/Migration.MD)
47+
## [Model](XCode/Model.MD)
48+
## [Normal](XCode/Normal.MD)
49+
## [Readme](XCode/Readme.MD)
50+
## [Search](XCode/Search.MD)
51+
## [SingleCache](XCode/SingleCache.MD)
52+
53+
# XCoder
54+
## [Readme](XCoder/Readme.MD)
55+
56+
# XScript
57+
## [Readme](XScript/Readme.MD)
58+
59+
# XTemplate
60+
## [Readme](XTemplate/Readme.MD)

articles/toc.yml

-45
This file was deleted.

build/PowerShellProject1.pssproj

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<PropertyGroup>
3+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4+
<SchemaVersion>2.0</SchemaVersion>
5+
<ProjectGuid>{a3746209-cf63-423b-b96a-bb2edcb1b00b}</ProjectGuid>
6+
<OutputType>Exe</OutputType>
7+
<RootNamespace>MyApplication</RootNamespace>
8+
<AssemblyName>MyApplication</AssemblyName>
9+
<Name>PowerShellProject1</Name>
10+
</PropertyGroup>
11+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
12+
<DebugSymbols>true</DebugSymbols>
13+
<DebugType>full</DebugType>
14+
<Optimize>false</Optimize>
15+
<OutputPath>bin\Debug\</OutputPath>
16+
<DefineConstants>DEBUG;TRACE</DefineConstants>
17+
<ErrorReport>prompt</ErrorReport>
18+
<WarningLevel>4</WarningLevel>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
21+
<DebugType>pdbonly</DebugType>
22+
<Optimize>true</Optimize>
23+
<OutputPath>bin\Release\</OutputPath>
24+
<DefineConstants>TRACE</DefineConstants>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
</PropertyGroup>
28+
<ItemGroup>
29+
<Folder Include="articles\" />
30+
</ItemGroup>
31+
<ItemGroup>
32+
<Compile Include="..\articles\build-toc.ps1">
33+
<Link>articles\build-toc.ps1</Link>
34+
</Compile>
35+
<Compile Include="build-toc.ps1" />
36+
<Compile Include="build.ps1">
37+
</Compile>
38+
</ItemGroup>
39+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
40+
<Target Name="Build" />
41+
<Import Project="$(MSBuildExtensionsPath)\PowerShell Tools for Visual Studio\PowerShellTools.targets" Condition="Exists('$(MSBuildExtensionsPath)\PowerShell Tools for Visual Studio\PowerShellTools.targets')" />
42+
</Project>

build/PowerShellProject1.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27703.2042
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{F5034706-568F-408A-B7B3-4D38C6DB8A32}") = "PowerShellProject1", "PowerShellProject1.pssproj", "{A3746209-CF63-423B-B96A-BB2EDCB1B00B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{A3746209-CF63-423B-B96A-BB2EDCB1B00B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A3746209-CF63-423B-B96A-BB2EDCB1B00B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A3746209-CF63-423B-B96A-BB2EDCB1B00B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A3746209-CF63-423B-B96A-BB2EDCB1B00B}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {1B2034ED-EC63-4AEA-81D8-6D0D65453BBB}
24+
EndGlobalSection
25+
EndGlobal

0 commit comments

Comments
 (0)