예제 #1
0
        private void ValidateOptions(MongoDbCacheOptions cacheOptions)
        {
            if (!string.IsNullOrEmpty(cacheOptions.ConnectionString) && cacheOptions.MongoClientSettings == null)
            {
                throw new ArgumentException(
                          $"Only one of {nameof(cacheOptions.ConnectionString)} and {nameof(cacheOptions.MongoClientSettings)} can be set.");
            }

            if (string.IsNullOrEmpty(cacheOptions.ConnectionString) && cacheOptions.MongoClientSettings == null)
            {
                throw new ArgumentException(
                          $"{nameof(cacheOptions.ConnectionString)} or {nameof(cacheOptions.MongoClientSettings)} cannot be empty or null.");
            }

            if (string.IsNullOrEmpty(cacheOptions.DatabaseName))
            {
                throw new ArgumentException(
                          $"{nameof(cacheOptions.DatabaseName)} cannot be empty or null.");
            }

            if (string.IsNullOrEmpty(cacheOptions.CollectionName))
            {
                throw new ArgumentException(
                          $"{nameof(cacheOptions.CollectionName)} cannot be empty or null.");
            }
        }
예제 #2
0
        private void ValidateOptions(MongoDbCacheOptions cacheOptions)
        {
            if (string.IsNullOrEmpty(cacheOptions.ConnectionString))
            {
                throw new ArgumentException(
                          $"{nameof(cacheOptions.ConnectionString)} cannot be empty or null.");
            }

            if (string.IsNullOrEmpty(cacheOptions.DatabaseName))
            {
                throw new ArgumentException(
                          $"{nameof(cacheOptions.DatabaseName)} cannot be empty or null.");
            }

            if (string.IsNullOrEmpty(cacheOptions.CollectionName))
            {
                throw new ArgumentException(
                          $"{nameof(cacheOptions.CollectionName)} cannot be empty or null.");
            }
        }