|
1 | | -using JetBrains.Annotations; |
2 | 1 | using Microsoft.EntityFrameworkCore; |
3 | 2 |
|
4 | 3 | namespace BitzArt.XDoc; |
5 | 4 |
|
6 | 5 | /// <summary> |
7 | | -/// Configures XML documentation comments for Entity Framework Core entities and their properties. |
| 6 | +/// Extensions for configuring XML documentation comments for Entity Framework Core entities. |
8 | 7 | /// </summary> |
9 | | -[PublicAPI] |
10 | | -public class EntitiesDocumentationConfigurator |
| 8 | +public static class ModelBuilderExtensions |
11 | 9 | { |
12 | | - private readonly XDoc _xDoc; |
13 | | - |
14 | | - /// <summary> |
15 | | - /// Default constructor. |
16 | | - /// </summary> |
17 | | - public EntitiesDocumentationConfigurator(XDoc xDoc) |
18 | | - { |
19 | | - _xDoc = xDoc; |
20 | | - } |
21 | | - |
22 | 10 | /// <summary> |
23 | | - /// Configure comments for entities and properties. |
| 11 | + /// Configures XML documentation comments for Entity Framework Core entities and their properties. |
24 | 12 | /// </summary> |
25 | 13 | /// <param name="modelBuilder"></param> |
26 | | - public void ConfigureComments(ModelBuilder modelBuilder) |
| 14 | + /// <param name="xDoc"></param> |
| 15 | + public static void ConfigureComments(this ModelBuilder modelBuilder, XDoc xDoc) |
27 | 16 | { |
28 | 17 | var entityTypes = modelBuilder.Model.GetEntityTypes(); |
29 | 18 |
|
30 | 19 | foreach (var entityType in entityTypes) |
31 | 20 | { |
32 | | - var typeDocumentation = _xDoc.Get(entityType.ClrType); |
| 21 | + var typeDocumentation = xDoc.Get(entityType.ClrType); |
33 | 22 |
|
34 | 23 | if (typeDocumentation is null) |
35 | 24 | { |
@@ -67,7 +56,7 @@ public void ConfigureComments(ModelBuilder modelBuilder) |
67 | 56 | continue; |
68 | 57 | } |
69 | 58 |
|
70 | | - var propertyDocumentation = _xDoc.Get(propertyInfo); |
| 59 | + var propertyDocumentation = xDoc.Get(propertyInfo); |
71 | 60 |
|
72 | 61 | if (propertyDocumentation is null) |
73 | 62 | { |
|
0 commit comments