Ejemplo n.º 1
0
        private ServiceCollection SetUpGoogleServiceCollection()
        {
            var googleSettings = new GoogleClientSettings()
            {
                Url = "http://test.com"
            };

            var services = new ServiceCollection();

            services.AddSingleton(googleSettings);
            services.AddSingleton <Profile, Google.AutoMapperProfile>();
            services.AddSingleton(
                sp =>
            {
                var profiles = sp.GetServices <Profile>();
                return(new MapperConfiguration(
                           config =>
                {
                    foreach (var profile in profiles)
                    {
                        config.AddProfile(profile);
                    }
                })
                       .CreateMapper(sp.GetService));
            });

            return(services);
        }
Ejemplo n.º 2
0
        public GoogleFileService(IOptions <GoogleClientSettings> googleClientSettings)
        {
            _googleClientSettings = googleClientSettings.Value;
            var filePath   = Environment.GetEnvironmentVariable("GoogleCredentialsFilePath");
            var credential = GoogleCredential.FromFile(filePath);

            _storageClient = StorageClient.Create(credential);
        }