【繁星Code】如何在EF将实体注释写入数据库中

时间:2022-05-27 22:33:16

最近在项目中需要把各个字段的释义写到数据库中,该项目已经上线很长时间了,数据库中的字段没有上千也有上百个,要是一个项目一个项目打开然后再去找对应字段查看什么意思,估计要到明年过年了。由于项目中使用EntityFramework,本身这个项目只有手动设置字段注释的功能,Coder平时写代码的时候都懒得写注释,更别提能在配置数据库的时候将注释配置进去,所以如何在EF中自动将实体注释写入数据库,减轻Coder的压力(ru he tou lan)尤为重要。gitee地址:https://gitee.com/lbqman/Blog20210206.git 。下面进入正题。

一、实现思路

        在FluentAPI中提供了HasComment方法,如下
 
 
 
 
 
11
 
 
 
1
    /// <summary>Configures a comment to be applied to the column</summary>
2
    /// <typeparam name="TProperty"> The type of the property being configured. </typeparam>
3
    /// <param name="propertyBuilder"> The builder for the property being configured. </param>
4
    /// <param name="comment"> The comment for the column. </param>
5
    /// <returns> The same builder instance so that multiple calls can be chained. </returns>
6
    public static PropertyBuilder<TProperty> HasComment<TProperty>(
7
      [NotNull] this PropertyBuilder<TProperty> propertyBuilder,
8
      [CanBeNull] string comment)
9
    {
10
      return (PropertyBuilder<TProperty>) propertyBuilder.HasComment(comment);
11
    }
 
 
也就是说我们要获取到实体对象的注释xml,然后读取对应的字段注释,自动调用改方法即可。需要解决的问题大概有以下几点。
  1. 如何获取当前配置的字段;
  2. 加载Xml,并根据字段获取对应的注释;
  3. 如何将枚举的各项信息都放入注释中;

二、实现方法

1.如何获取当前配置的字段

       在获取xml的注释中,需要的信息有实体对应的类型以及对应的字段。而包含这两种类型的方法只有Property这个方法,该方法的出入参如下:
 
 
 
 
 
2
 
 
 
1
public virtual PropertyBuilder<TProperty> Property<TProperty>(
2
      [NotNull] Expression<Func<TEntity, TProperty>> propertyExpression);
 
 
        所以我们准备对这个方法进行改造。并且根据传入的propertyExpression获取字段名称。方法如下:
 
 
 
 
 
4
 
 
 
1
        public static PropertyBuilder<TProperty> SummaryProperty<TEntity, TProperty>(
2
            this EntityTypeBuilder<TEntity> entityTypeBuilder,
3
            Expression<Func<TEntity, TProperty>> propertyExpression)
4
            where TEntity : class
 
 
        根据表达式获取字段名称如下:
 
 
 
 
 
10
 
 
 
1
        public static MemberInfo GetMember<T, TProperty>(this Expression<Func<T, TProperty>> expression)
2
        {
3
            MemberExpression memberExp;
4
            if (expression.Body is UnaryExpression unaryExpression)
5
                memberExp = unaryExpression.Operand as MemberExpression;
6
            else
7
                memberExp = expression.Body as MemberExpression;
8

9
            return memberExp?.Member;
10
        }
 
 

2.加载Xml,并根据字段获取对应的注释

    VS中的Xml格式不在此处过多解释,属性、方法等注释可以根据规律去获取。此处需要注意的是当字段是从父类继承而来并且父类属于不同的dll时,需要获取父类所在dll的xml注释才行,另外枚举也需要同样去处理。虽然获取Xml数据的方法只在更新数据库时才调用,但是还是需要使用字典将数据缓存下来,方便下次快速获取。具体代码如下:
 
 
 
 
 
204
 
 
 
1
   /// <summary>
2
    /// xml注释获取器
3
    /// </summary>
4
    internal static class SummaryXmlCacheProvider
5
    {
6
        #region TClass
7

8
        /// <summary>
9
        /// 根据类型初始化该类所在程序集的xml
10
        /// </summary>
11
        /// <typeparam name="TClass"></typeparam>
12
        internal static void InitSummaryXml<TClass>()
13
        {
14
            var assembly = Assembly.GetAssembly(typeof(TClass));
15
            SerializeXmlFromAssembly(assembly);
16
        }
17

18
        /// <summary>
19
        /// 根据类型获取该类所在程序集的xml
20
        /// </summary>
21
        /// <typeparam name="TClass"></typeparam>
22
        /// <returns></returns>
23
        internal static Dictionary<string, string> GetSummaryXml<TClass>()
24
        {
25
            var assembly = Assembly.GetAssembly(typeof(TClass));
26
            return SummaryCache[assembly];
27
        }
28

29
        /// <summary>
30
        /// 获取该类在xml的key
31
        /// </summary>
32
        /// <typeparam name="TClass"></typeparam>
33
        /// <returns></returns>
34
        internal static string GetClassTypeKey<TClass>()
35
        {
36
            return TableSummaryRuleProvider.TypeSummaryKey(typeof(TClass).FullName);
37
        }
38

39
        #endregion
40

41
        #region TProperty
42

43
        /// <summary>
44
        /// 根据类型以及字段初始化该类所在程序集的xml
45
        /// </summary>
46
        /// <typeparam name="TClass"></typeparam>
47
        /// <typeparam name="TProperty"></typeparam>
48
        /// <param name="propertyExpression"></param>
49
        internal static void InitSummaryXml<TClass, TProperty>(Expression<Func<TClass, TProperty>> propertyExpression)
50
        {
51
            var propertyAssembly = GetPropertyAssembly(propertyExpression);
52
            SerializeXmlFromAssembly(propertyAssembly);
53
        }
54

55
        /// <summary>
56
        /// 根据类型以及字段获取该类所在程序集的xml
57
        /// </summary>
58
        /// <typeparam name="TClass"></typeparam>
59
        /// <typeparam name="TProperty"></typeparam>
60
        /// <param name="propertyExpression"></param>
61
        /// <returns></returns>
62
        internal static Dictionary<string, string> GetSummaryXml<TClass, TProperty>(
63
            Expression<Func<TClass, TProperty>> propertyExpression)
64
        {
65
            var propertyAssembly = GetPropertyAssembly(propertyExpression);
66
            return SummaryCache[propertyAssembly];
67
        }
68

69
        /// <summary>
70
        /// 获取该类以及字段所在xml的key
71
        /// </summary>
72
        /// <typeparam name="TClass"></typeparam>
73
        /// <typeparam name="TProperty"></typeparam>
74
        /// <param name="propertyExpression"></param>
75
        /// <returns></returns>
76
        internal static string GetPropertyTypeKey<TClass, TProperty>(
77
            Expression<Func<TClass, TProperty>> propertyExpression)
78
        {
79
            var memberName = propertyExpression.GetMember().Name;
80
            var propertyInfo = GetPropertyInfo(propertyExpression);
81
            var propertyKey =
82
                $"{propertyInfo.DeclaringType.Namespace}.{propertyInfo.DeclaringType.Name}.{memberName}";
83
            return PropertySummaryRuleProvider.PropertyTypeSummaryKey(propertyKey);
84
        }
85

86
        #endregion
87

88
        #region TEnum
89

90
        /// <summary>
91
        /// 获取枚举字段的描述信息
92
        /// </summary>
93
        /// <typeparam name="TClass"></typeparam>
94
        /// <typeparam name="TProperty"></typeparam>
95
        /// <param name="propertyExpression"></param>
96
        /// <returns></returns>
97
        internal static string GetEnumPropertyDescription<TClass, TProperty>(Expression<Func<TClass, TProperty>> propertyExpression)
98
        {
99
            var propertyInfo = GetPropertyInfo(propertyExpression);
100
            if (!propertyInfo.PropertyType.IsEnum)
101
                return string.Empty;
102
            var enumType = propertyInfo.PropertyType;
103
            SerializeXmlFromAssembly(enumType.Assembly);
104
            var propertySummaryDic = SummaryCache[enumType.Assembly];
105
            var enumNames = enumType.GetEnumNames();
106
            var enumDescDic = enumType.GetNameAndValues();
107
            var enumSummaries = new List<string>();
108
            foreach (var enumName in enumNames)
109
            {
110
                var propertyEnumKey = PropertySummaryRuleProvider.EnumTypeSummaryKey($"{enumType.FullName}.{enumName}");
111
                var enumSummary = propertySummaryDic.ContainsKey(propertyEnumKey)
112
                    ? propertySummaryDic[propertyEnumKey]
113
                    : string.Empty;
114
                var enumValue = enumDescDic[enumName];
115
                enumSummaries.Add(PropertySummaryRuleProvider.EnumTypeSummaryFormat(enumValue,enumName,enumSummary));
116
            }
117

118
            return string.Join(";", enumSummaries);
119

120
        }
121

122
        #endregion
123

124
        /// <summary>
125
        /// 根据表达式获取属性所在的程序集
126
        /// </summary>
127
        /// <typeparam name="TClass"></typeparam>
128
        /// <typeparam name="TProperty"></typeparam>
129
        /// <param name="propertyExpression"></param>
130
        /// <returns></returns>
131
        private static Assembly GetPropertyAssembly<TClass, TProperty>(
132
            Expression<Func<TClass, TProperty>> propertyExpression)
133
        {
134
            var propertyInfo = GetPropertyInfo(propertyExpression);
135
            var propertyAssembly = propertyInfo.Module.Assembly;
136
            return propertyAssembly;
137
        }
138

139
        /// <summary>
140
        /// 根据表达式获取字段属性
141
        /// </summary>
142
        /// <typeparam name="TClass"></typeparam>
143
        /// <typeparam name="TProperty"></typeparam>
144
        /// <param name="propertyExpression"></param>
145
        /// <returns></returns>
146
        private static PropertyInfo GetPropertyInfo<TClass, TProperty>(
147
            Expression<Func<TClass, TProperty>> propertyExpression)
148
        {
149
            var entityType = typeof(TClass);
150
            var memberName = propertyExpression.GetMember().Name;
151
            var propertyInfo = entityType.GetProperty(memberName, typeof(TProperty));
152
            if (propertyInfo == null || propertyInfo.DeclaringType == null)
153
                throw new ArgumentNullException($"this property {memberName} is not belong to {entityType.Name}");
154

155
            return propertyInfo;
156
        }
157

158
        /// <summary>
159
        /// 根据程序集初始化xml
160
        /// </summary>
161
        /// <param name="assembly"></param>
162
        private static void SerializeXmlFromAssembly(Assembly assembly)
163
        {
164
            var assemblyPath = assembly.Location;
165
            var lastIndexOf = assemblyPath.LastIndexOf(".dll", StringComparison.Ordinal);
166
            var xmlPath = assemblyPath.Remove(lastIndexOf, 4) + ".xml";
167

168
            if (SummaryCache.ContainsKey(assembly))
169
                return;
170
            var xmlDic = new Dictionary<string, string>();
171
            if (!File.Exists(xmlPath))
172
            {
173
                Console.WriteLine($"未能加载xml文件,原因:xml文件不存在,path:{xmlPath}");
174
                SummaryCache.Add(assembly, xmlDic);
175
                return;
176
            }
177

178
            var doc = new XmlDocument();
179
            doc.Load(xmlPath);
180
            var members = doc.SelectNodes("doc/members/member");
181
            if (members == null)
182
            {
183
                Console.WriteLine($"未能加载xml文件,原因:doc/members/member节点不存在");
184
                SummaryCache.Add(assembly, xmlDic);
185
                return;
186
            }
187

188
            foreach (XmlElement member in members)
189
            {
190
                var name = member.Attributes["name"].InnerText.Trim();
191
                if (string.IsNullOrWhiteSpace(name))
192
                    continue;
193
                xmlDic.Add(name, member.SelectSingleNode("summary")?.InnerText.Trim());
194
            }
195

196
            SummaryCache.Add(assembly, xmlDic);
197
        }
198

199
        /// <summary>
200
        /// xml注释缓存
201
        /// </summary>
202
        private static Dictionary<Assembly, Dictionary<string, string>> SummaryCache { get; } =
203
            new Dictionary<Assembly, Dictionary<string, string>>();
204
    }
 
 

3.如何将枚举的各项信息都放入注释中

  上面的两个步骤已经根据表达式将字段的注释获取到,直接调用EF提供的HasComment即可。见代码:
 
 
 
 
 
15
 
 
 
1
        public static PropertyBuilder<TProperty> SummaryProperty<TEntity, TProperty>(
2
            this EntityTypeBuilder<TEntity> entityTypeBuilder,
3
            Expression<Func<TEntity, TProperty>> propertyExpression)
4
            where TEntity : class
5
        {
6
            SummaryXmlCacheProvider.InitSummaryXml(propertyExpression);
7
            var entitySummaryDic = SummaryXmlCacheProvider.GetSummaryXml(propertyExpression);
8
            var propertyKey = SummaryXmlCacheProvider.GetPropertyTypeKey(propertyExpression);
9
            var summary = entitySummaryDic.ContainsKey(propertyKey) ? entitySummaryDic[propertyKey] : string.Empty;
10
            var enumDescription = SummaryXmlCacheProvider.GetEnumPropertyDescription(propertyExpression);
11
            summary = string.IsNullOrWhiteSpace(enumDescription) ? summary : $"{summary}:{enumDescription}";
12
            return string.IsNullOrWhiteSpace(summary)
13
                ? entityTypeBuilder.Property(propertyExpression)
14
                : entityTypeBuilder.Property(propertyExpression).HasComment(summary);
15
        }
 
 
  同时也可以设置表的注释以及表的名称。如下:
 
 
 
 
 
26
 
 
 
1
public static EntityTypeBuilder<TEntity> SummaryToTable<TEntity>(
2
            this EntityTypeBuilder<TEntity> entityTypeBuilder, bool hasTableComment = true,
3
            Func<string> tablePrefix = null)
4
            where TEntity : class
5
        {
6
            var tableName = GetTableName<TEntity>(tablePrefix);
7
            return hasTableComment
8
                ? entityTypeBuilder.ToTable(tableName)
9
                    .SummaryHasComment()
10
                : entityTypeBuilder.ToTable(tableName);
11
        }
12

13
        public static EntityTypeBuilder<TEntity> SummaryHasComment<TEntity>(
14
            this EntityTypeBuilder<TEntity> entityTypeBuilder) where TEntity : class
15
        {
16
            SummaryXmlCacheProvider.InitSummaryXml<TEntity>();
17
            var entityDic = SummaryXmlCacheProvider.GetSummaryXml<TEntity>();
18
            var tableKey = SummaryXmlCacheProvider.GetClassTypeKey<TEntity>();
19
            var summary = entityDic.ContainsKey(tableKey) ? entityDic[tableKey] : string.Empty;
20
            return string.IsNullOrWhiteSpace(summary) ? entityTypeBuilder : entityTypeBuilder.HasComment(summary);
21
        }
22

23
        private static string GetTableName<TEntity>(Func<string> tablePrefix)
24
        {
25
            return typeof(TEntity).Name.Replace("Entity", $"Tb{tablePrefix?.Invoke()}");
26
        }
 
 
  搞定。

三、效果展示

  运行Add-Migration InitDb即可查看生成的代码。
 
 
 
 
 
 
 
 
 
 
 
1
    public partial class InitDb : Migration
2
    {
3
        protected override void Up(MigrationBuilder migrationBuilder)
4
        {
5
            migrationBuilder.CreateTable(
6
                name: "TbGood",
7
                columns: table => new
8
                {
9
                    Id = table.Column<long>(nullable: false, comment: "主键")
10
                        .Annotation("SqlServer:Identity", "1, 1"),
11
                    CreateTime = table.Column<DateTime>(nullable: false, comment: "创建时间"),
12
                    CreateName = table.Column<string>(maxLength: 64, nullable: false, comment: "创建人姓名"),
13
                    UpdateTime = table.Column<DateTime>(nullable: true, comment: "更新时间"),
14
                    UpdateName = table.Column<string>(maxLength: 64, nullable: true, comment: "更新人姓名"),
15
                    Name = table.Column<string>(maxLength: 64, nullable: false, comment: "商品名称"),
16
                    GoodType = table.Column<int>(nullable: false, comment: "物品类型:(0,Electronic) 电子产品;(1,Clothes) 衣帽服装;(2,Food) 食品;(3,Other) 其他物品"),
17
                    Description = table.Column<string>(maxLength: 2048, nullable: true, comment: "物品描述"),
18
                    Store = table.Column<int>(nullable: false, comment: "储存量")
19
                },
20
                constraints: table =>
21
                {
22
                    table.PrimaryKey("PK_TbGood", x => x.Id);
23
                },
24
                comment: "商品实体类");
25

26
            migrationBuilder.CreateTable(
27
                name: "TbOrder",
28
                columns: table => new
29
                {
30
                    Id = table.Column<long>(nullable: false, comment: "主键")
31
                        .Annotation("SqlServer:Identity", "1, 1"),
32
                    CreateTime = table.Column<DateTime>(nullable: false, comment: "创建时间"),
33
                    CreateName = table.Column<string>(maxLength: 64, nullable: false, comment: "创建人姓名"),
34
                    UpdateTime = table.Column<DateTime>(nullable: true, comment: "更新时间"),
35
                    UpdateName = table.Column<string>(maxLength: 64, nullable: true, comment: "更新人姓名"),
36
                    GoodId = table.Column<long>(nullable: false, comment: "商品Id"),
37
                    OrderStatus = table.Column<int>(nullable: false, comment: "订单状态:(0,Ordered) 已下单;(1,Payed) 已付款;(2,Complete) 已付款;(3,Cancel) 已取消"),
38
                    OrderTime = table.Column<DateTime>(nullable: false, comment: "下订单时间"),
39
                    Address = table.Column<string>(maxLength: 2048, nullable: false, comment: "订单地址"),
40
                    UserName = table.Column<string>(maxLength: 16, nullable: false, comment: "收件人姓名"),
41
                    TotalAmount = table.Column<decimal>(nullable: false, comment: "总金额")
42
                },
43
                constraints: table =>
44
                {
45
                    table.PrimaryKey("PK_TbOrder", x => x.Id);
46
                },
47
                comment: "订单实体类");
48
        }
49

50
        protected override void Down(MigrationBuilder migrationBuilder)
51
        {
52
            migrationBuilder.DropTable(
53
                name: "TbGood");
54

55
            migrationBuilder.DropTable(
56
                name: "TbOrder");
57
        }
58
    }
 
 

四、写在最后

  此种方法是在我目前能想起来比较方便生成注释的方法了,另外还想过EntityTypeBuilder中的Property方法,最后还是放弃了,因为EntityTypeBuilder是由ModelBuilder生成,而ModelBuilder又是ModelSource中的CreateModel方法产生,最后一路深扒到DbContext中,为了搞这个注释得不偿失,最后才采取了上述的方法。若是大佬有更好的方法,恭请分享。

.wiz-editor-body .wiz-code-container { position: relative; padding: 8px 0; margin: 5px 0; text-indent: 0; text-align: left }
.CodeMirror { font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; color: rgba(0, 0, 0, 1); font-size: 0.875rem }
.wiz-editor-body .wiz-code-container .CodeMirror div { margin-top: 0; margin-bottom: 0 }
.CodeMirror-lines { padding: 4px 0 }
.CodeMirror pre.CodeMirror-line, .CodeMirror pre.CodeMirror-line-like { padding: 0 4px }
.CodeMirror pre.CodeMirror-line { min-height: 24px }
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { background-color: rgba(255, 255, 255, 1) }
.CodeMirror-gutters { border-right: 1px solid rgba(221, 221, 221, 1); background-color: rgba(247, 247, 247, 1); white-space: nowrap }
.CodeMirror-linenumbers { }
.CodeMirror-linenumber { padding: 0 3px 0 5px; min-width: 20px; text-align: right; color: rgba(153, 153, 153, 1); white-space: nowrap }
.CodeMirror-guttermarker { color: rgba(0, 0, 0, 1) }
.CodeMirror-guttermarker-subtle { color: rgba(153, 153, 153, 1) }
.CodeMirror-cursor { border-left: 1px solid rgba(0, 0, 0, 1); border-right: none; width: 0 }
.CodeMirror div.CodeMirror-secondarycursor { border-left: 1px solid rgba(192, 192, 192, 1) }
.cm-fat-cursor .CodeMirror-cursor { width: auto; border: 0 !important; background: rgba(119, 238, 119, 1) }
.cm-fat-cursor div.CodeMirror-cursors { z-index: 1 }
.cm-fat-cursor-mark { background-color: rgba(20, 255, 20, 0.5); -webkit-animation: blink 1.06s steps(1) infinite; -moz-animation: blink 1.06s steps(1) infinite; animation: 1.06s step-end infinite blink }
.cm-animate-fat-cursor { width: auto; border: 0; -webkit-animation: blink 1.06s steps(1) infinite; -moz-animation: blink 1.06s steps(1) infinite; animation: 1.06s step-end infinite blink; background-color: rgba(119, 238, 119, 1) }
@-moz-keyframes blink { 0% {} 50% { background-color: transparent; } 100% {}}
@-webkit-keyframes blink { 0% {} 50% { background-color: transparent; } 100% {}}
@keyframes blink { 0% { } 50% { background-color: rgba(0, 0, 0, 0) } 100% { } }
.CodeMirror-overwrite .CodeMirror-cursor { }
.cm-tab { display: inline-block }
.CodeMirror-rulers { position: absolute; left: 0; right: 0; top: -50px; bottom: -20px; overflow: hidden }
.CodeMirror-ruler { border-left: 1px solid rgba(204, 204, 204, 1); top: 0; bottom: 0; position: absolute }
.cm-s-default .cm-header { color: rgba(0, 0, 255, 1) }
.cm-s-default .cm-quote { color: rgba(0, 153, 0, 1) }
.cm-negative { color: rgba(221, 68, 68, 1) }
.cm-positive { color: rgba(34, 153, 34, 1) }
.cm-header, .cm-strong { font-weight: bold }
.cm-em { font-style: italic }
.cm-link { text-decoration: underline }
.cm-strikethrough { text-decoration: line-through }
.cm-s-default .cm-keyword { color: rgba(119, 0, 136, 1) }
.cm-s-default .cm-atom { color: rgba(34, 17, 153, 1) }
.cm-s-default .cm-number { color: rgba(17, 102, 68, 1) }
.cm-s-default .cm-def { color: rgba(0, 0, 255, 1) }
.cm-s-default .cm-variable, .cm-s-default .cm-punctuation, .cm-s-default .cm-property, .cm-s-default .cm-operator { }
.cm-s-default .cm-variable-2 { color: rgba(0, 85, 170, 1) }
.cm-s-default .cm-variable-3 { color: rgba(0, 136, 85, 1) }
.cm-s-default .cm-comment { color: rgba(170, 85, 0, 1) }
.cm-s-default .cm-string { color: rgba(170, 17, 17, 1) }
.cm-s-default .cm-string-2 { color: rgba(255, 85, 0, 1) }
.cm-s-default .cm-meta { color: rgba(85, 85, 85, 1) }
.cm-s-default .cm-qualifier { color: rgba(85, 85, 85, 1) }
.cm-s-default .cm-builtin { color: rgba(51, 0, 170, 1) }
.cm-s-default .cm-bracket { color: rgba(153, 153, 119, 1) }
.cm-s-default .cm-tag { color: rgba(17, 119, 0, 1) }
.cm-s-default .cm-attribute { color: rgba(0, 0, 204, 1) }
.cm-s-default .cm-hr { color: rgba(153, 153, 153, 1) }
.cm-s-default .cm-link { color: rgba(0, 0, 204, 1) }
.cm-s-default .cm-error { color: rgba(255, 0, 0, 1) }
.cm-invalidchar { color: rgba(255, 0, 0, 1) }
.CodeMirror-composing { border-bottom: 2px solid }
div.CodeMirror span.CodeMirror-matchingbracket { color: rgba(0, 187, 0, 1) }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgba(170, 34, 34, 1) }
.CodeMirror-matchingtag { background: rgba(255, 150, 0, 0.3) }
.CodeMirror-activeline-background { background: rgba(232, 242, 255, 1) }
.CodeMirror { position: relative; background: rgba(245, 245, 245, 1) }
.CodeMirror-scroll { overflow: hidden !important; margin-bottom: 0; margin-right: -30px; padding: 16px 30px 16px 0; outline: none; position: relative }
.CodeMirror-sizer { position: relative; border-right: 30px solid rgba(0, 0, 0, 0) }
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { position: absolute; z-index: 6; display: none }
.CodeMirror-vscrollbar { right: 0; top: 0; overflow-x: hidden; overflow-y: scroll }
.CodeMirror-hscrollbar { bottom: 0; left: 0 !important; overflow-y: hidden; overflow-x: scroll; pointer-events: auto !important; outline: none }
.CodeMirror-scrollbar-filler { right: 0; bottom: 0 }
.CodeMirror-gutter-filler { left: 0; bottom: 0 }
.CodeMirror-gutters { position: absolute; left: 0; top: 0; min-height: 100%; z-index: 3 }
.CodeMirror-gutter { white-space: normal; height: 100%; display: inline-block; vertical-align: top; margin-bottom: -30px }
.CodeMirror-gutter-wrapper { position: absolute; z-index: 4; border: none !important }
.CodeMirror-gutter-background { position: absolute; top: 0; bottom: 0; z-index: 4 }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4 }
.CodeMirror-gutter-wrapper ::selection { background-color: rgba(0, 0, 0, 0) }
{ background-color: rgba(0, 0, 0, 0) }
.CodeMirror-lines { cursor: text; min-height: 1px }
.CodeMirror pre.CodeMirror-line, .CodeMirror pre.CodeMirror-line-like { -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; border-width: 0; background: rgba(0, 0, 0, 0); font-family: inherit; font-size: inherit; margin: 0; white-space: pre; word-wrap: normal; line-height: inherit; color: inherit; z-index: 2; position: relative; overflow: visible; -webkit-tap-highlight-color: transparent; -webkit-font-variant-ligatures: contextual; font-variant-ligatures: contextual }
.CodeMirror-wrap pre.CodeMirror-line, .CodeMirror-wrap pre.CodeMirror-line-like { word-wrap: break-word; white-space: pre-wrap; word-break: normal }
.CodeMirror-linebackground { position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: 0 }
.CodeMirror-linewidget { position: relative; z-index: 2; padding: 0.1px }
.CodeMirror-widget { }
.CodeMirror-rtl pre { direction: rtl }
.CodeMirror-code { outline: none }
.CodeMirror-scroll, .CodeMirror-sizer, .CodeMirror-gutter, .CodeMirror-gutters, .CodeMirror-linenumber { -moz-box-sizing: content-box; box-sizing: content-box }
.CodeMirror-measure { position: absolute; width: 100%; height: 0; overflow: hidden; visibility: hidden }
.CodeMirror-cursor { position: absolute; pointer-events: none }
.CodeMirror-measure pre { position: static }
div.CodeMirror-cursors { visibility: hidden; position: relative; z-index: 3 }
div.CodeMirror-dragcursors { visibility: visible }
.CodeMirror-focused div.CodeMirror-cursors { visibility: visible }
.CodeMirror-selected { background: rgba(217, 217, 217, 1) }
.CodeMirror-focused .CodeMirror-selected { background: rgba(215, 212, 240, 1) }
.CodeMirror-crosshair { cursor: crosshair }
.CodeMirror-line::selection, .CodeMirror-line>span::selection, .CodeMirror-line>span>span::selection { background: rgba(215, 212, 240, 1) }
{ background: rgba(215, 212, 240, 1) }
.cm-searching { background: rgba(255, 255, 0, 0.4) }
.cm-force-border { padding-right: 0.1px }
@media print { .CodeMirror div.CodeMirror-cursors { visibility: hidden } }
.cm-tab-wrap-hack:after { content: "" }
span.CodeMirror-selectedtext { }
.CodeMirror-activeline-background, .CodeMirror-selected { transition: visibility 0ms 100ms }
.CodeMirror-blur .CodeMirror-activeline-background, .CodeMirror-blur .CodeMirror-selected { visibility: hidden }
.CodeMirror-blur .CodeMirror-matchingbracket { color: inherit !important; outline: none !important; text-decoration: none !important }
.CodeMirror-sizer { }
.cm-s-material.CodeMirror { background-color: rgba(38, 50, 56, 1); color: rgba(233, 237, 237, 1) }
.cm-s-material .CodeMirror-gutters { background: rgba(38, 50, 56, 1); color: rgba(83, 127, 126, 1); border: none }
.cm-s-material .CodeMirror-guttermarker, .cm-s-material .CodeMirror-guttermarker-subtle, .cm-s-material .CodeMirror-linenumber { color: rgba(83, 127, 126, 1) }
.cm-s-material .CodeMirror-cursor { border-left: 1px solid rgba(248, 248, 240, 1) }
.cm-s-material div.CodeMirror-selected { background: rgba(255, 255, 255, 0.15) }
.cm-s-material.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.1) }
.cm-s-material .CodeMirror-line::selection, .cm-s-material .CodeMirror-line>span::selection, .cm-s-material .CodeMirror-line>span>span::selection { background: rgba(255, 255, 255, 0.1) }
{ background: rgba(255, 255, 255, 0.1) }
.cm-s-material .CodeMirror-activeline-background { background: rgba(0, 0, 0, 0) }
.cm-s-material .cm-keyword { color: rgba(199, 146, 234, 1) }
.cm-s-material .cm-operator { color: rgba(233, 237, 237, 1) }
.cm-s-material .cm-variable-2 { color: rgba(128, 203, 196, 1) }
.cm-s-material .cm-variable-3 { color: rgba(130, 177, 255, 1) }
.cm-s-material .cm-builtin { color: rgba(222, 203, 107, 1) }
.cm-s-material .cm-atom { color: rgba(247, 118, 105, 1) }
.cm-s-material .cm-number { color: rgba(247, 118, 105, 1) }
.cm-s-material .cm-def { color: rgba(233, 237, 237, 1) }
.cm-s-material .cm-string { color: rgba(195, 232, 141, 1) }
.cm-s-material .cm-string-2 { color: rgba(128, 203, 196, 1) }
.cm-s-material .cm-comment { color: rgba(84, 110, 122, 1) }
.cm-s-material .cm-variable { color: rgba(130, 177, 255, 1) }
.cm-s-material .cm-tag { color: rgba(128, 203, 196, 1) }
.cm-s-material .cm-meta { color: rgba(128, 203, 196, 1) }
.cm-s-material .cm-attribute { color: rgba(255, 203, 107, 1) }
.cm-s-material .cm-property { color: rgba(128, 203, 174, 1) }
.cm-s-material .cm-qualifier { color: rgba(222, 203, 107, 1) }
.cm-s-material .cm-variable-3 { color: rgba(222, 203, 107, 1) }
.cm-s-material .cm-tag { color: rgba(255, 83, 112, 1) }
.cm-s-material .cm-error { color: rgba(255, 255, 255, 1); background-color: rgba(236, 95, 103, 1) }
.cm-s-material .CodeMirror-matchingbracket { text-decoration: underline; color: rgba(255, 255, 255, 1) !important }
html, .wiz-editor-body { font-size: 12pt }
.wiz-editor-body { font-family: Helvetica, "Hiragino Sans GB", "微软雅黑", "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 1.7; margin: 0 auto; position: relative; padding: 20px 16px }
.wiz-editor-body h1, .wiz-editor-body h2, .wiz-editor-body h3, .wiz-editor-body h4, .wiz-editor-body h5, .wiz-editor-body h6 { margin: 1.25rem 0 0.625rem; padding: 0; font-weight: bold }
.wiz-editor-body h1 { font-size: 1.67rem }
.wiz-editor-body h2 { font-size: 1.5rem }
.wiz-editor-body h3 { font-size: 1.25rem }
.wiz-editor-body h4 { font-size: 1.17rem }
.wiz-editor-body h5 { font-size: 1rem }
.wiz-editor-body h6 { font-size: 1rem; color: rgba(119, 119, 119, 1); margin: 1rem 0 }
.wiz-editor-body div, .wiz-editor-body p, .wiz-editor-body ul, .wiz-editor-body ol, .wiz-editor-body dl, .wiz-editor-body li { margin: 8px 0 0 }
.wiz-editor-body blockquote, .wiz-editor-body table, .wiz-editor-body pre, .wiz-editor-body code { margin: 8px 0 }
.wiz-editor-body .CodeMirror pre { margin: 0 }
.wiz-editor-body a { word-wrap: break-word; text-decoration-skip-ink: none }
.wiz-editor-body ul, .wiz-editor-body ol { padding-left: 2rem }
.wiz-editor-body ol.wiz-list-level1>li { list-style-type: decimal }
.wiz-editor-body ol.wiz-list-level2>li { list-style-type: lower-latin }
.wiz-editor-body ol.wiz-list-level3>li { list-style-type: lower-roman }
.wiz-editor-body li.wiz-list-align-style { list-style-position: inside; margin-left: -1em }
.wiz-editor-body blockquote { padding: 0 12px }
.wiz-editor-body blockquote>:first-child { margin-top: 0 }
.wiz-editor-body blockquote>:last-child { margin-bottom: 0 }
.wiz-editor-body img { border: 0; max-width: 100%; height: auto !important; margin: 2px 0; padding: 2px; vertical-align: bottom }
.wiz-editor-body table { border-collapse: collapse; border: 1px solid rgba(167, 175, 188, 1) }
.wiz-editor-body td, .wiz-editor-body th { padding: 4px 8px; border-collapse: collapse; border: 1px solid rgba(167, 175, 188, 1); min-height: 28px; box-sizing: border-box }
.wiz-editor-body td>div:first-child { margin-top: 0 }
.wiz-editor-body td>div:last-child { margin-bottom: 0 }
.wiz-editor-body img.wiz-svg-image { box-shadow: 1px 1px 4px rgba(232, 232, 232, 1) }
.wiz-editor-body .wiz-image-container { margin: 0; max-width: 100%; display: inline-flex; flex-direction: column }
.wiz-editor-body .wiz-image-container .wiz-image-title { display: inline-block; text-align: center; color: rgba(167, 175, 188, 1); line-height: 18px; font-size: 12px; min-height: 18px; width: 100%; white-space: normal }
.wiz-hide { display: none !important }
.wiz-editor-body.wiz-editor-outline { padding-right: 0; padding-left: 0 }
.wiz-editor-body.wiz-editor-outline .outline-container { margin: 0; padding: 0; line-height: 1.5 }
.wiz-editor-body.wiz-editor-outline .outline-container div { margin: 0 }
.wiz-editor-body.wiz-editor-outline .node { margin: 0; padding: 0 }
.wiz-editor-body.wiz-editor-outline .outline-container>.node { margin-right: 24px; margin-left: 30px }
.wiz-editor-body.wiz-editor-outline .node.collapsed .children { display: none }
.wiz-editor-body.wiz-editor-outline .node .row { position: relative; padding-left: 26px }
.wiz-editor-body.wiz-editor-outline .node .operator-container { width: 36px; position: absolute; top: 4px; left: -18px }
.wiz-editor-body.wiz-editor-outline .node .operator-bar { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center }
.wiz-editor-body.wiz-editor-outline .node .switch { width: 18px; height: 18px; display: flex; flex-direction: column; align-items: center; overflow: hidden }
.wiz-editor-body.wiz-editor-outline .node .switch i { font-size: 20px; position: relative; left: -1px; top: -1px }
.wiz-editor-body.wiz-editor-outline .node .switch.active { cursor: pointer; color: rgba(0, 0, 0, 0); transition: transform 200ms ease 0s }
.wiz-editor-body.wiz-editor-outline .node.collapsed .switch.active { transform: rotateY(-90deg) }
.wiz-editor-body.wiz-editor-outline .node .row:hover .switch.active { color: rgba(80, 95, 121, 1) }
.wiz-editor-body.wiz-editor-outline .node .dot { display: flex; align-items: center; justify-content: center; border-radius: 100%; width: 18px; height: 18px }
.wiz-editor-body.wiz-editor-outline .node.collapsed .dot { background-color: rgba(80, 95, 121, 0.15) }
.wiz-editor-body.wiz-editor-outline .node .dot-icon { background-color: rgba(80, 95, 121, 1); border-radius: 100%; width: 6px; height: 6px }
.wiz-editor-body.wiz-editor-outline .node .child { margin-left: 8px; border-left: 1px solid rgba(230, 233, 237, 1); padding-left: 17px }
.wiz-editor-body.wiz-editor-outline .node .content { flex: 1; outline: none; padding: 4px 0 }
.wiz-editor-body.wiz-editor-outline .node div.content { font-size: 1rem }
.wiz-editor-body.wiz-editor-outline .node.complete>.row .content { text-decoration: line-through; color: rgba(167, 175, 188, 1) }
.wiz-editor-body.wiz-editor-outline .node .notes { outline: none; font-size: 0.8rem; color: rgba(167, 175, 188, 1) }
.wiz-editor-body.wiz-editor-outline .node .image { outline: none; padding-top: 4px; padding-bottom: 4px }
.wiz-editor-body.wiz-editor-outline .outline-container h1, .wiz-editor-body.wiz-editor-outline .outline-container h2, .wiz-editor-body.wiz-editor-outline .outline-container h3, .wiz-editor-body.wiz-editor-outline .outline-container h4, .wiz-editor-body.wiz-editor-outline .outline-container h5, .wiz-editor-body.wiz-editor-outline .outline-container h6 { margin: 0 }
body, .wiz-editor-body { padding-left: 48px; padding-right: 48px }