abp

Форк
0
/
MyProjectNameModuleExtensionConfigurator.cs 
68 строк · 2.3 Кб
1
using Volo.Abp.Threading;
2

3
namespace MyCompanyName.MyProjectName;
4

5
public static class MyProjectNameModuleExtensionConfigurator
6
{
7
    private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
8

9
    public static void Configure()
10
    {
11
        OneTimeRunner.Run(() =>
12
        {
13
            ConfigureExistingProperties();
14
            ConfigureExtraProperties();
15
        });
16
    }
17

18
    private static void ConfigureExistingProperties()
19
    {
20
        /* You can change max lengths for properties of the
21
         * entities defined in the modules used by your application.
22
         *
23
         * Example: Change user and role name max lengths
24

25
           AbpUserConsts.MaxNameLength = 99;
26
           IdentityRoleConsts.MaxNameLength = 99;
27

28
         * Notice: It is not suggested to change property lengths
29
         * unless you really need it. Go with the standard values wherever possible.
30
         *
31
         * If you are using EF Core, you will need to run the add-migration command after your changes.
32
         */
33
    }
34

35
    private static void ConfigureExtraProperties()
36
    {
37
        /* You can configure extra properties for the
38
         * entities defined in the modules used by your application.
39
         *
40
         * This class can be used to define these extra properties
41
         * with a high level, easy to use API.
42
         *
43
         * Example: Add a new property to the user entity of the identity module
44

45
           ObjectExtensionManager.Instance.Modules()
46
              .ConfigureIdentity(identity =>
47
              {
48
                  identity.ConfigureUser(user =>
49
                  {
50
                      user.AddOrUpdateProperty<string>( //property type: string
51
                          "SocialSecurityNumber", //property name
52
                          property =>
53
                          {
54
                              //validation rules
55
                              property.Attributes.Add(new RequiredAttribute());
56
                              property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4});
57

58
                              //...other configurations for this property
59
                          }
60
                      );
61
                  });
62
              });
63

64
         * See the documentation for more:
65
         * https://docs.abp.io/en/abp/latest/Module-Entity-Extensions
66
         */
67
    }
68
}
69

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.