コード例 #1
0
        private void ConfigureAzure()
        {
            // 注入,然后实例化
            IocManager.Register <AzureConfigs>();
            var azureConfigs = IocManager.Resolve <AzureConfigs>();

            // 读取配置文件并反序列化
            var auzreSettingsContent = _env.GetJsonFileContent("azuresettings");
            var tmpAzureConfigs      = JsonConvert.DeserializeObject <AzureConfigs>(auzreSettingsContent);

            // 将临时配置对象中的引用给Ioc实例化对象
            azureConfigs.ComputerVisionOCR        = tmpAzureConfigs.ComputerVisionOCR;
            azureConfigs.ComputerVisionImgAnalyze = tmpAzureConfigs.ComputerVisionImgAnalyze;
            azureConfigs.SpeechToText             = tmpAzureConfigs.SpeechToText;
            azureConfigs.TextToSpeech             = tmpAzureConfigs.TextToSpeech;
        }