public void InstallServices(IServiceCollection services, IConfiguration configuration) { var settings = configuration.GetSection("CosmosSettings"); var cosmosStoreSettings = new CosmosStoreSettings(settings["DatabaseName"], settings["AccountUri"], settings["AccountKey"], new ConnectionPolicy()); services.AddCosmosStore <CosmosPostDto>(cosmosStoreSettings); }
public MainGenericDb(AgroDbArguments args) { var storeSettings = new CosmosStoreSettings(args.NameDb, args.EndPointUrl, args.PrimaryKey); Store = new CosmosStore <T>(storeSettings); BatchStore = new CosmosStore <EntityContainer>(storeSettings); }
private void SetupCosmos(IServiceCollection services) { var databaseName = Configuration.GetValue <string>("CosmosDb:DatabaseName"); var endpointUrl = Configuration.GetValue <string>("CosmosDb:Account"); var authKey = Configuration.GetValue <string>("CosmosDb:AuthKey"); var settings = new CosmosStoreSettings(databaseName, endpointUrl, authKey) { JsonSerializerSettings = new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = new List <JsonConverter> { new Newtonsoft.Json.Converters.StringEnumConverter() }, NullValueHandling = NullValueHandling.Ignore } }; //Register stores here services.AddCosmosStore <Director>(settings); services.AddCosmosStore <Sponsor>(settings); services.AddCosmosStore <BrandingSponsorship>(settings); services.AddCosmosStore <Sponsorship>(settings); services.AddCosmosStore <Setting>(settings); services.AddCosmosStore <Advertisement>(settings); services.AddCosmosStore <EtapesterySetting>(settings); services.AddCosmosStore <Contender>(settings); services.AddCosmosStore <FoodTruck>(settings); services.AddCosmosStore <Liquor>(settings); services.AddCosmosStore <ToastAdvertisement>(settings); services.AddCosmosStore <ToastSponsor>(settings); services.AddCosmosStore <ToastSponsorship>(settings); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { string databaseName = Configuration.GetSection("CosmosSettings:DatabaseName").Value; string databaseUri = Configuration.GetSection("CosmosSettings:DatabaseUri").Value; string authKey = Configuration.GetSection("CosmosSettings:DatabaseKey").Value; CosmosStoreSettings cosmosSettings = new CosmosStoreSettings(databaseName, databaseUri, authKey); services.AddCosmosStore <User>(cosmosSettings); services.AddCosmosStore <TodoItem>(cosmosSettings); services.AddSingleton <IUserRepository, UserRepository>(); services.AddSingleton <ITodoItemRepository, TodoItemRepository>(); services.AddGraphQLServices(); services.AddGraphQL() .AddSystemTextJson(); services.AddSwaggerGen(c => { c.SwaggerDoc(name: "v1", new OpenApiInfo { Title = "REST API", Version = "v1" }); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.XML"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); services.AddControllers(); }
public async Task CosmosStoreSettings_CreatesCollectionWithUniqueKeyPolicy() { var cosmosStoreSettings = new CosmosStoreSettings(_databaseId, _emulatorUri, _emulatorKey, settings => { settings.ProvisionInfrastructureIfMissing = true; settings.ConnectionPolicy = _connectionPolicy; settings.UniqueKeyPolicy = new UniqueKeyPolicy { UniqueKeys = { new UniqueKey { Paths = { "/name", "/bladiebla" } } } }; }); var store = new CosmosStore <Lion>(cosmosStoreSettings); var collection = await store.CosmonautClient.GetCollectionAsync(_databaseId, store.CollectionName); collection.UniqueKeyPolicy.UniqueKeys.Should().HaveCount(1); }
public FamilyServiceCosmonaut(CosmosStoreSettings cosmonaultStore, ILogger <FamilyServiceCosmonaut> logger) { _cosmonaultStore = cosmonaultStore; _logger = logger; store = new CosmosStore <Family>(_cosmonaultStore); }
public static IServiceCollection ConfigureToolBox(this IServiceCollection services, CosmosDbSettings cosmosDbSettings) { var cosmosSettings = new CosmosStoreSettings( cosmosDbSettings.DatabaseId, cosmosDbSettings.URL, cosmosDbSettings.PrimaryKey); services.AddCosmosStore <MeUser>(cosmosSettings, "Users"); services.AddCosmosStore <Location>(cosmosSettings, "Locations"); services.AddCosmosStore <Examination>(cosmosSettings, "Examinations"); services.AddScoped <IDocumentClientFactory, DocumentClientFactory>(); services.AddScoped <IDatabaseAccess, DatabaseAccess>(); services.AddScoped <IUserConnectionSettings>(s => new UserConnectionSettings( new Uri(cosmosDbSettings.URL), cosmosDbSettings.PrimaryKey, cosmosDbSettings.DatabaseId)); services.AddScoped <IAsyncQueryHandler <UserRetrievalByIdQuery, MeUser>, UserRetrievalByIdService>(); services.AddScoped <IAsyncQueryHandler <UserUpdateQuery, MeUser>, UserUpdateService>(); services.AddScoped <IAsyncQueryHandler <UsersRetrievalQuery, IEnumerable <MeUser> >, UsersRetrievalService>(); services.AddScoped <ImpersonateUserService>(); services.AddScoped <GenerateConfigurationService>(); services.AddScoped <ImportDocumentService>(); services.AddScoped <GetLocationTreeService>(); return(services); }
public static IServiceCollection InjectCosmosStore <TQuery, TModel>(this IServiceCollection services, CosmosConfig config) where TQuery : class where TModel : class { if (config.DatabaseName == null || config.EndpointUri == null || config.PrimaryKey == null) { // allow server to be started up without these settings // in case they're just trying to seed their environment // in the future we'll remove this in favor of centralized seeding capability return(services); } var settings = new CosmosStoreSettings(config.DatabaseName, config.EndpointUri, config.PrimaryKey, new ConnectionPolicy { ConnectionProtocol = Protocol.Tcp, ConnectionMode = ConnectionMode.Direct, RequestTimeout = config.RequestTimeout }, defaultCollectionThroughput: 400) { UniqueKeyPolicy = new UniqueKeyPolicy() { UniqueKeys = (Collection <UniqueKey>) typeof(TModel).GetMethod("GetUniqueKeys")?.Invoke(null, null) ?? new Collection <UniqueKey>() } }; services.AddSingleton(typeof(TQuery), typeof(TQuery)); return(services.AddCosmosStore <TModel>(settings)); }
public static IServiceProvider GetServices() { var serviceCollection = new ServiceCollection(); var cosmosDbUri = Environment.GetEnvironmentVariable("CosmosDbUri"); var cosmosDbKey = Environment.GetEnvironmentVariable("CosmosDbKey"); var iotHubConnectionString = Environment.GetEnvironmentVariable("IotHubConnectionString"); var cosmosSettings = new CosmosStoreSettings("turino-iot", new Uri(cosmosDbUri), cosmosDbKey); JsonConvert.DefaultSettings = () => new JsonSerializerSettings { Formatting = Formatting.Indented, ContractResolver = new CamelCasePropertyNamesContractResolver() }; serviceCollection.AddCosmosStore <Device>(cosmosSettings); serviceCollection.AddTransient <DeviceStatusCommandHandler>(); serviceCollection.AddTransient <GetDevicesQueryHandler>(); serviceCollection.AddTransient <GetDeviceQueryHandler>(); serviceCollection.AddTransient <SwitchDeviceLightCommandHandler>(); serviceCollection.AddTransient(s => ServiceClient.CreateFromConnectionString(iotHubConnectionString)); serviceCollection.AddTransient <IDeviceRepository, DeviceRepository>(); return(serviceCollection.BuildServiceProvider()); }
public static void AddCosmosDependencies(this IServiceCollection services, IConfiguration configuration) { var cosmosSettings = new CosmosStoreSettings("nbaplayers", "https://cvzeu2playersapicdb.documents.azure.com:443/", "A37an6Ph0HbdFbteDC2cwwVeFIZyKYEdfjbINxd0tEQJ5driobTd7wmYLbTMUQspYmnkxSnhfwKbfkUOqucn7A=="); services.AddCosmosStore <PlayerDocument>(cosmosSettings); }
public void InstallService(IServiceCollection services, IConfiguration configuration) { var cosmosStoreSettings = new CosmosStoreSettings(configuration["CosmosSettings:DatabaseName"], configuration["CosmosSettings:AccountUri"], configuration["CosmosSettings:AccountKey"], new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp }); services.AddCosmosStore <Domain.Post>(cosmosStoreSettings); // similar to EF DbSet }
private static IServiceCollection AddPersistedGrantCosmonautStore( this IServiceCollection services, CosmosStoreSettings settings, string overriddenCollectionName = "") { services.AddCosmosStore <PersistedGrantEntity>(settings, overriddenCollectionName); return(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var setting = new CosmosStoreSettings("tutorial", "https://localhost:8081", "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", defaultCollectionThroughput: 1000); services.AddCosmosStore <Car>(setting); services.AddMvc(); }
public static IServiceCollection AddCosmosStore <TEntity>(this IServiceCollection services, string databaseName, Uri endpointUri, string authKey, Action <CosmosStoreSettings> settingsAction = null, string overriddenCollectionName = "") where TEntity : class { var settings = new CosmosStoreSettings(databaseName, endpointUri, authKey); settingsAction?.Invoke(settings); return(services.AddCosmosStore <TEntity>(settings, overriddenCollectionName)); }
public void IntallServices(IServiceCollection services, IConfiguration configuration) { var cosmosStoreSettings = new CosmosStoreSettings(configuration["CosmosSettings:DatabaseName"], configuration["CosmosSettings:AccountUri"], configuration["CosmosSettings:AccountKey"], new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var setting = new CosmosStoreSettings("carmanagement", "https://car-management.documents.azure.com:443/", "Nl2jtiIGLKGqaMkPNpZuIPw36KFBvrIkTQOEdt7Y408SU8UXKcv3e3SPTGCAgHubYALvfj5rcdRuXrNdiYSHLQ==", defaultCollectionThroughput: 1000); services.AddCosmosStore <Car>(setting); services.AddMvc(); }
/// <summary> /// Add Operational Store /// </summary> /// <param name="builder">The IIdentity Server Builder</param> /// <param name="setupAction"></param> /// <param name="tokenCleanUpOptions"></param> /// <returns></returns> public static IIdentityServerBuilder AddOperationalStore( this IIdentityServerBuilder builder, CosmosStoreSettings settings, string overriddenCollectionName = "") { builder.Services.AddPersistedGrantCosmonautStore(settings, overriddenCollectionName); builder.Services.AddTransient <IPersistedGrantStore, PersistedGrantStore>(); return(builder); }
public static IIdentityServerBuilder AddCosmonautIdentityServerCacheStore( this IIdentityServerBuilder builder, CosmosStoreSettings settings, string overriddenCollectionName = "") { builder.Services.AddIdentityServerCacheCosmonautStore(settings, overriddenCollectionName); builder.Services.AddTransient(typeof(ICache <>), typeof(CosmonautCache <>)); return(builder); }
private static void AddCosmosStore(CosmosStoreSettings cosmosSettings, ServiceCollection serviceCollection, MethodInfo CreateListInternalMethod, Type ObjectType) { //this method is actually an extension,https://github.com/Elfocrash/Cosmonaut/blob/develop/src/Cosmonaut.Extensions.Microsoft.DependencyInjection/ServiceCollectionExtensions.cs var generic = CreateListInternalMethod.MakeGenericMethod(ObjectType); generic.Invoke(serviceCollection, new object[3] { serviceCollection, cosmosSettings, "" }); }
private static IServiceCollection AddIdentityServerCacheCosmonautStore( this IServiceCollection services, CosmosStoreSettings settings, string overriddenCollectionName = "") { services.AddTransient <ICacheStore <CacheItem>, CacheStore>(); services.AddCosmosStore <CacheEntity>(settings, overriddenCollectionName); return(services); }
public void AddOperationalStore(IServiceCollection services, IIdentityServerBuilder builder) { bool useRedis = Convert.ToBoolean(Configuration["appOptions:redis:useRedis"]); bool useCosmos = Convert.ToBoolean(Configuration["appOptions:cosmos:useCosmos"]); if (useCosmos) { /* * * "identityServerOperationalStore": { * "database": "identityServer", * "collection": "operational" * } */ var uri = Configuration["appOptions:cosmos:uri"]; var primaryKey = Configuration["appOptions:cosmos:primaryKey"]; var databaseName = Configuration["appOptions:cosmos:identityServerOperationalStore:database"]; var collection = Configuration["appOptions:cosmos:identityServerOperationalStore:collection"]; var cosmosStoreSettings = new CosmosStoreSettings( databaseName, uri, primaryKey, s => { s.ConnectionPolicy = _connectionPolicy; }); builder.AddOperationalStore(cosmosStoreSettings, collection); builder.AddCosmonautIdentityServerCacheStore(cosmosStoreSettings, collection); } else if (useRedis) { var redisConnectionString = Configuration["appOptions:redis:redisConnectionString"]; builder.AddOperationalStore(options => { options.RedisConnectionString = redisConnectionString; options.Db = 1; }) .AddRedisCaching(options => { options.RedisConnectionString = redisConnectionString; options.KeyPrefix = "prefix"; }); services.AddDistributedRedisCache(options => { options.Configuration = redisConnectionString; }); } else { builder.AddInMemoryCaching(); builder.AddInMemoryPersistedGrants(); services.AddDistributedMemoryCache(); } }
public void ValidStringEndpointCreatesUri() { // Arrange var expectedUri = new Uri("http://test.com"); // Act var settings = new CosmosStoreSettings("dbName", "http://test.com", "key"); // Assert Assert.Equal(expectedUri, settings.EndpointUrl); }
public void InstallServices(IServiceCollection services, IConfiguration configuration) { var cosmosStoreSettings = new CosmosStoreSettings(configuration["CosmosSettings:DatabaseName"], configuration["CosmosSettings:AccountUri"], configuration["CosmosSettings:AccountKey"], new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp }); services.AddCosmosStore <CosmosPostDto>(cosmosStoreSettings); // probably like that }
void IInstaller.InstallService(IConfiguration configuration, IServiceCollection services) { var cosmosStoreSettings = new CosmosStoreSettings( configuration["CosmosSettings:DatabaseName"], configuration["CosmosSettings:AccountUri"], configuration["CosmosSettings:AccountKey"], new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp }); services.AddCosmosStore <CosmosPostDto>(cosmosStoreSettings); }
public void InstallServices(IServiceCollection services, IConfiguration configuration) { var cosmosStoreSettings = new CosmosStoreSettings( databaseName: configuration["CosmosSettings:DatabaseName"], endpointUrl: configuration["CosmosSettings:AccountUri"], authKey: configuration["CosmosSettings:AccountKey"], new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp }); //services.AddCosmosStore<CosmosPostDto>(cosmosStoreSettings);will fix later }
public static IIdentityServerBuilder AddCosmonautResourceStore( this IIdentityServerBuilder builder, CosmosStoreSettings settings, string overriddenApiResourceCollectionName = "", string overriddenIdentityResourceCollectionName = "") { builder.Services.TryAddTransient <IResourceStore, ResourcesStore>(); builder.Services.TryAddTransient <IFullResourceStore, ResourcesStore>(); builder.Services.AddCosmosStore <ApiResourceEntity>(settings, overriddenApiResourceCollectionName); builder.Services.AddCosmosStore <IdentityResourceEntity>(settings, overriddenIdentityResourceCollectionName); return(builder); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var setting = new CosmosStoreSettings("cryptocurrencies", "https://kendouiexample.documents.azure.com:443/", "b8wSOhaGWdsk2I2ZWYF3jY8kLjDaIaXC8Sc7W9L7QYF2fz28V6Dez48IIdlyey5CNAPIUvBNWfQmFoDpTdr39A==", defaultCollectionThroughput: 400); services.AddCosmosStore <CryptoViewModel>(setting); services .AddMvc() .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()); services.AddKendo(); }
public Repozitorijum(ILoggerFactory dnevnikFabrika, IKonfiguracijaServis konfiguracijaServis) { _dnevnik = dnevnikFabrika.CreateLogger <Repozitorijum <T> >(); _konfiguracijaServis = konfiguracijaServis; _cosmosStorePodesavanja = new CosmosStoreSettings( _konfiguracijaServis.CosmosDbNazivBaze, _konfiguracijaServis.CosmosDbUrl, _konfiguracijaServis.CosmosDbAutKljuc); _cosmosStore = new CosmosStore <T>(_cosmosStorePodesavanja); }
public void RegisterSevices(IServiceCollection services, IConfiguration configuration) { var cosmosStroeSetting = new CosmosStoreSettings( configuration["CosmosSettings:DatabaseName"], configuration["CosmosSettings:AccountUri"], configuration["CosmosSettings:AccountKey"], new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp }); services.AddCosmosStore <CosmosProduct>(cosmosStroeSetting); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); var dbSettings = new DatabaseSettings(); Configuration.Bind(nameof(DatabaseSettings), dbSettings); var cosmosStoreSettings = new CosmosStoreSettings(dbSettings.DatabaseName, dbSettings.DatabaseUrl, dbSettings.DatabaseKey, new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp }); services.AddCosmosStore <Customer>(cosmosStoreSettings); }