Exemplo n.º 1
0
        public RealtimeService(IRealtimeServer server, IOptions <SiteOptions> siteOptions,
                               IOptions <DataAccessOptions> dataAccessOptions, IOptions <RealtimeOptions> realtimeOptions,
                               IOptions <AuthOptions> authOptions, IMongoClient mongoClient, IConfiguration configuration)
        {
            Server             = server;
            _siteOptions       = siteOptions;
            _dataAccessOptions = dataAccessOptions;
            _realtimeOptions   = realtimeOptions;
            _authOptions       = authOptions;
            _database          = mongoClient.GetDatabase(_dataAccessOptions.Value.MongoDatabaseName);
            _configuration     = configuration;

            RealtimeOptions options = _realtimeOptions.Value;

            _docConfigs = new Dictionary <Type, DocConfig>();
            AddDocConfig(options.UserDoc);
            AddDocConfig(options.ProjectDoc);
            foreach (DocConfig projectDataDoc in options.ProjectDataDocs)
            {
                AddDocConfig(projectDataDoc);
            }
            foreach (DocConfig userDataDoc in options.UserDataDocs)
            {
                AddDocConfig(userDataDoc);
            }
        }
Exemplo n.º 2
0
            public TestEnvironment()
            {
                IRealtimeServer              realtimeServer    = Substitute.For <IRealtimeServer>();
                IOptions <SiteOptions>       siteOptions       = Substitute.For <IOptions <SiteOptions> >();
                IOptions <DataAccessOptions> dataAccessOptions =
                    Microsoft.Extensions.Options.Options.Create <DataAccessOptions>(new DataAccessOptions()
                {
                    MongoDatabaseName = "mongoDatabaseName"
                });
                IOptions <RealtimeOptions> realtimeOptions =
                    Microsoft.Extensions.Options.Options.Create <RealtimeOptions>(new RealtimeOptions()
                {
                    ProjectDoc      = new DocConfig("some_projects", typeof(Project)),
                    ProjectDataDocs = new List <DocConfig>
                    {
                        new DocConfig("favorite_numbers", typeof(int)),
                        new DocConfig("favorite_things", typeof(object)),
                        new DocConfig("favorite_verses", typeof(string))
                    },
                    UserDataDocs = new List <DocConfig>
                    {
                        new DocConfig("favorite_animals", typeof(object)),
                    }
                });
                IOptions <AuthOptions> authOptions = Substitute.For <IOptions <AuthOptions> >();

                IMongoClient mongoClient = Substitute.For <IMongoClient>();

                mongoClient.GetDatabase(Arg.Any <string>()).Returns(MongoDatabase);
                IConfiguration configuration = Substitute.For <IConfiguration>();

                Service = new RealtimeService(realtimeServer, siteOptions, dataAccessOptions, realtimeOptions,
                                              authOptions, mongoClient, configuration);
            }
Exemplo n.º 3
0
 internal Document(IRealtimeServer server, int connHandle, string otTypeName, string collection, string id)
 {
     _server     = server;
     _connHandle = connHandle;
     OTTypeName  = otTypeName;
     Collection  = collection;
     Id          = id;
 }