-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19625 from abpframework/nolayers
Add GlobalFeatureConfigurator and ModuleExtensionConfigurator to nolayers template
- Loading branch information
Showing
30 changed files
with
808 additions
and
2 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...MyCompanyName.MyProjectName.Blazor.Server.Mongo/MyProjectNameGlobalFeatureConfigurator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Volo.Abp.Threading; | ||
|
||
namespace MyCompanyName.MyProjectName; | ||
|
||
public static class MyProjectNameGlobalFeatureConfigurator | ||
{ | ||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); | ||
|
||
public static void Configure() | ||
{ | ||
OneTimeRunner.Run(() => | ||
{ | ||
/* You can configure (enable/disable) global features of the used modules here. | ||
* Please refer to the documentation to learn more about the Global Features System: | ||
* https://docs.abp.io/en/abp/latest/Global-Features | ||
*/ | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...CompanyName.MyProjectName.Blazor.Server.Mongo/MyProjectNameModuleExtensionConfigurator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using Volo.Abp.Threading; | ||
|
||
namespace MyCompanyName.MyProjectName; | ||
|
||
public static class MyProjectNameModuleExtensionConfigurator | ||
{ | ||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); | ||
|
||
public static void Configure() | ||
{ | ||
OneTimeRunner.Run(() => | ||
{ | ||
ConfigureExistingProperties(); | ||
ConfigureExtraProperties(); | ||
}); | ||
} | ||
|
||
private static void ConfigureExistingProperties() | ||
{ | ||
/* You can change max lengths for properties of the | ||
* entities defined in the modules used by your application. | ||
* | ||
* Example: Change user and role name max lengths | ||
AbpUserConsts.MaxNameLength = 99; | ||
IdentityRoleConsts.MaxNameLength = 99; | ||
* Notice: It is not suggested to change property lengths | ||
* unless you really need it. Go with the standard values wherever possible. | ||
* | ||
* If you are using EF Core, you will need to run the add-migration command after your changes. | ||
*/ | ||
} | ||
|
||
private static void ConfigureExtraProperties() | ||
{ | ||
/* You can configure extra properties for the | ||
* entities defined in the modules used by your application. | ||
* | ||
* This class can be used to define these extra properties | ||
* with a high level, easy to use API. | ||
* | ||
* Example: Add a new property to the user entity of the identity module | ||
ObjectExtensionManager.Instance.Modules() | ||
.ConfigureIdentity(identity => | ||
{ | ||
identity.ConfigureUser(user => | ||
{ | ||
user.AddOrUpdateProperty<string>( //property type: string | ||
"SocialSecurityNumber", //property name | ||
property => | ||
{ | ||
//validation rules | ||
property.Attributes.Add(new RequiredAttribute()); | ||
property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4}); | ||
//...other configurations for this property | ||
} | ||
); | ||
}); | ||
}); | ||
* See the documentation for more: | ||
* https://docs.abp.io/en/abp/latest/Module-Entity-Extensions | ||
*/ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...ompanyName.MyProjectName.Blazor.Server/Data/MyProjectNameEfCoreEntityExtensionMappings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Volo.Abp.Threading; | ||
|
||
namespace MyCompanyName.MyProjectName.Data; | ||
|
||
public static class MyProjectNameEfCoreEntityExtensionMappings | ||
{ | ||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); | ||
|
||
public static void Configure() | ||
{ | ||
MyProjectNameGlobalFeatureConfigurator.Configure(); | ||
MyProjectNameModuleExtensionConfigurator.Configure(); | ||
|
||
OneTimeRunner.Run(() => | ||
{ | ||
/* You can configure extra properties for the | ||
* entities defined in the modules used by your application. | ||
* | ||
* This class can be used to map these extra properties to table fields in the database. | ||
* | ||
* USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING. | ||
* USE MyProjectNameModuleExtensionConfigurator CLASS (in the Domain.Shared project) | ||
* FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES | ||
* | ||
* Example: Map a property to a table field: | ||
ObjectExtensionManager.Instance | ||
.MapEfCoreProperty<IdentityUser, string>( | ||
"MyProperty", | ||
(entityBuilder, propertyBuilder) => | ||
{ | ||
propertyBuilder.HasMaxLength(128); | ||
} | ||
); | ||
* See the documentation for more: | ||
* https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities | ||
*/ | ||
}); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...-core/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameGlobalFeatureConfigurator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Volo.Abp.Threading; | ||
|
||
namespace MyCompanyName.MyProjectName; | ||
|
||
public static class MyProjectNameGlobalFeatureConfigurator | ||
{ | ||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); | ||
|
||
public static void Configure() | ||
{ | ||
OneTimeRunner.Run(() => | ||
{ | ||
/* You can configure (enable/disable) global features of the used modules here. | ||
* Please refer to the documentation to learn more about the Global Features System: | ||
* https://docs.abp.io/en/abp/latest/Global-Features | ||
*/ | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...ore/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameModuleExtensionConfigurator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using Volo.Abp.Threading; | ||
|
||
namespace MyCompanyName.MyProjectName; | ||
|
||
public static class MyProjectNameModuleExtensionConfigurator | ||
{ | ||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); | ||
|
||
public static void Configure() | ||
{ | ||
OneTimeRunner.Run(() => | ||
{ | ||
ConfigureExistingProperties(); | ||
ConfigureExtraProperties(); | ||
}); | ||
} | ||
|
||
private static void ConfigureExistingProperties() | ||
{ | ||
/* You can change max lengths for properties of the | ||
* entities defined in the modules used by your application. | ||
* | ||
* Example: Change user and role name max lengths | ||
AbpUserConsts.MaxNameLength = 99; | ||
IdentityRoleConsts.MaxNameLength = 99; | ||
* Notice: It is not suggested to change property lengths | ||
* unless you really need it. Go with the standard values wherever possible. | ||
* | ||
* If you are using EF Core, you will need to run the add-migration command after your changes. | ||
*/ | ||
} | ||
|
||
private static void ConfigureExtraProperties() | ||
{ | ||
/* You can configure extra properties for the | ||
* entities defined in the modules used by your application. | ||
* | ||
* This class can be used to define these extra properties | ||
* with a high level, easy to use API. | ||
* | ||
* Example: Add a new property to the user entity of the identity module | ||
ObjectExtensionManager.Instance.Modules() | ||
.ConfigureIdentity(identity => | ||
{ | ||
identity.ConfigureUser(user => | ||
{ | ||
user.AddOrUpdateProperty<string>( //property type: string | ||
"SocialSecurityNumber", //property name | ||
property => | ||
{ | ||
//validation rules | ||
property.Attributes.Add(new RequiredAttribute()); | ||
property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4}); | ||
//...other configurations for this property | ||
} | ||
); | ||
}); | ||
}); | ||
* See the documentation for more: | ||
* https://docs.abp.io/en/abp/latest/Module-Entity-Extensions | ||
*/ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...yProjectName.Blazor.WebAssembly/Server/Data/MyProjectNameEfCoreEntityExtensionMappings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Volo.Abp.Threading; | ||
|
||
namespace MyCompanyName.MyProjectName.Data; | ||
|
||
public static class MyProjectNameEfCoreEntityExtensionMappings | ||
{ | ||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); | ||
|
||
public static void Configure() | ||
{ | ||
MyProjectNameGlobalFeatureConfigurator.Configure(); | ||
MyProjectNameModuleExtensionConfigurator.Configure(); | ||
|
||
OneTimeRunner.Run(() => | ||
{ | ||
/* You can configure extra properties for the | ||
* entities defined in the modules used by your application. | ||
* | ||
* This class can be used to map these extra properties to table fields in the database. | ||
* | ||
* USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING. | ||
* USE MyProjectNameModuleExtensionConfigurator CLASS (in the Domain.Shared project) | ||
* FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES | ||
* | ||
* Example: Map a property to a table field: | ||
ObjectExtensionManager.Instance | ||
.MapEfCoreProperty<IdentityUser, string>( | ||
"MyProperty", | ||
(entityBuilder, propertyBuilder) => | ||
{ | ||
propertyBuilder.HasMaxLength(128); | ||
} | ||
); | ||
* See the documentation for more: | ||
* https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities | ||
*/ | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...anyName.MyProjectName.Blazor.WebAssembly/Shared/MyProjectNameGlobalFeatureConfigurator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Volo.Abp.Threading; | ||
|
||
namespace MyCompanyName.MyProjectName; | ||
|
||
public static class MyProjectNameGlobalFeatureConfigurator | ||
{ | ||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); | ||
|
||
public static void Configure() | ||
{ | ||
OneTimeRunner.Run(() => | ||
{ | ||
/* You can configure (enable/disable) global features of the used modules here. | ||
* Please refer to the documentation to learn more about the Global Features System: | ||
* https://docs.abp.io/en/abp/latest/Global-Features | ||
*/ | ||
}); | ||
} | ||
} |
Oops, something went wrong.