Microsoft Azure Team developed
Function management (Feature Management) package
Microsoft.FeatureManagement Can be used to implement
Function switch , Can pass
Function switch Features dynamically change the behavior of the application without changing any business logic code . For more functions of the function switch, please see Edi Wang Of B Stop video ：
The focus of this article is to introduce how to Blazor WebAssembly Function switch is realized in the project .
adopt NuGet install
Microsoft.FeatureManagement , It can be done by Visual Studio 2019 Under the NuGet Package Manager Visual management interface perhaps adopt .NET CLI The command line tool enters the following command .
dotnet add package Microsoft.FeatureManagement
In order to be able to use
Function management , Need to be in
ConfigureServices The method was used in the experiment service Inject , As shown in the following code ：
There is one caveat ：
Function management Medium
Function switch The value read comes from the configuration file , If you want to make
Function switch Value from Configuration Different nodes of the file , Must be in service When you register, specify it separately .
In order to be able to Blazor Wassembly I use it in my life
Function management (feature management), We need to inject it into Blazor In the component ：
Call in use IFeatureManager Interface method IsEnabledAsync, The code is as follows ：
The usage is very simple , You can see .NET Right
Function management Provides out of the box support , It's really a very practical feature , More about Knowledge point Introduction to , Please refer to the official website ：
From this little article you can feel the use of blazor Can be .NET The whole ecology of the company is integrated into the front end , In this way blazor It's for you . For the screenshot code in this article, please refer to ：https://github.com/geffzhang/Abp.BootstrapTheme