Ejemplo n.º 1
0
        private static async Task InitializeAsync(string settingsFile = null)
        {
            using (Stream settingsStream = settingsFile == null
                ? Assembly.GetExecutingAssembly().GetManifestResourceStream("TestCLI.settings.json")
                : new FileStream(settingsFile, FileMode.Open, FileAccess.Read))
                using (var settingsReader = new StreamReader(settingsStream))
                    using (var textReader = new JsonTextReader(settingsReader))
                    {
                        dynamic settings = new JsonSerializer().Deserialize(textReader);

                        FaceServiceHelper.ApiKey    = settings.CognitiveServicesKeys.Face;
                        EmotionServiceHelper.ApiKey = settings.CognitiveServicesKeys.Emotion;
                        VisionServiceHelper.ApiKey  = settings.CognitiveServicesKeys.Vision;

                        BlobStorageHelper.ConnectionString = settings.AzureStorage.ConnectionString;
                        BlobStorageHelper.ContainerName    = settings.AzureStorage.BlobContainer;
                        blobStorage = await BlobStorageHelper.BuildAsync();

                        DocumentDBHelper.AccessKey      = settings.DocumentDB.Key;
                        DocumentDBHelper.EndpointUri    = settings.DocumentDB.EndpointURI;
                        DocumentDBHelper.DatabaseName   = settings.DocumentDB.DatabaseName;
                        DocumentDBHelper.CollectionName = settings.DocumentDB.CollectionName;
                        documentDb = await DocumentDBHelper.BuildAsync();
                    }
        }