Beispiel #1
0
        public void MaximalConfiguration()
        {
            string warning = null;
            var    builder = new FirestoreDbBuilder
            {
                ProjectId     = "proj",
                DatabaseId    = "db",
                CallInvoker   = new FakeCallInvoker(),
                WarningLogger = text => warning = text,
                Settings      = new FirestoreSettings {
                    Clock = new FakeClock()
                },
                ConverterRegistry = new ConverterRegistry {
                    new SerializationTestData.GuidConverter()
                }
            };
            var db = builder.Build();

            Assert.Equal("proj", db.ProjectId);
            Assert.Equal("db", db.DatabaseId);
            db.LogWarning("Test warning");
            Assert.Equal("Test warning", warning);
            Assert.IsType <FakeClock>(db.Client.Settings.Clock);
            Assert.IsType <CustomConverter <Guid> >(db.SerializationContext.GetConverter(typeof(Guid)));
        }
Beispiel #2
0
        public static FirestoreDb GenerateFireStore(string projectname, string path)
        {
            FirestoreDbBuilder builder = new FirestoreDbBuilder();

            builder.CredentialsPath = path;
            builder.ProjectId       = projectname;

            return(builder.Build());
        }
Beispiel #3
0
        private FirestoreDb GetDb()
        {
            var dbBuilder = new FirestoreDbBuilder
            {
                CredentialsPath = _configuration.GetValue <string>(CredentialsPath),
                ProjectId       = _configuration.GetValue <string>(ProjectId)
            };

            return(dbBuilder.Build());
        }
Beispiel #4
0
        public ExamService(string projectId, string jsonCredentials)
        {
            var dbBuilder = new FirestoreDbBuilder
            {
                ProjectId       = projectId,
                JsonCredentials = jsonCredentials
            };

            db = dbBuilder.Build();
        }
    private void MakeClient()
    {
        var credPath = BotSettings.GoogleCloudCredentialsPath.SanitizeSlash();

        Log.Information("Create Firestore client, cred {CredPath}", credPath);
        var clientBuilder = new FirestoreDbBuilder()
        {
            CredentialsPath = credPath,
            ProjectId       = ProjectId
        };

        var client = clientBuilder.Build();

        Db = client;
    }
        protected BaseRepo(FirestoreConfig firestoreConfig, ILogger logger)
        {
            log    = logger;
            config = firestoreConfig;
            if (config.Emulator)
            {
                if (string.IsNullOrEmpty(config.EmulatorUrl))
                {
                    throw new MissingFieldException(nameof(config.EmulatorUrl));
                }


                var fb = new FirestoreDbBuilder
                {
                    ProjectId = config.ProjectId,
                    //Endpoint = config.EmulatorUrl,
                    EmulatorDetection = EmulatorDetection.EmulatorOnly
                };

                db = fb.Build();
                return;
            }
            db = FirestoreDb.Create(config.ProjectId);
        }