当前位置:网站首页>How to use function switch in blazor webassembly

How to use function switch in blazor webassembly

2021-01-23 19:48:48 Zhang Shanyou

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 :

image

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 .

image

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 :

image

Call in use IFeatureManager Interface method IsEnabledAsync, The code is as follows :

image

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 :https://docs.microsoft.com/en-us/azure/azure-app-configuration/use-feature-flags-dotnet-core

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 


版权声明
本文为[Zhang Shanyou]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/01/20210123194824062Q.html

随机推荐