Exemple #1
0
        public MongoDbGenericRepository(IConfigurationHelper configurationHelper)
        {
            _configurationHelper = configurationHelper;

            var clientString = _configurationHelper.GetAppSettings("MongoDbClientString");
            var dbName       = _configurationHelper.GetAppSettings("MongoDbDatabaseName");

            var client = new MongoClient(clientString);

            _db = client.GetDatabase(dbName);
        }
        private IConnection GenerateConnection()
        {
            var factory = new ConnectionFactory()
            {
                UserName = _configurationHelper.GetAppSettings("Messaging:UserName"),
                Password = _configurationHelper.GetAppSettings("Messaging:Password"),
                HostName = _configurationHelper.GetAppSettings("Messaging:HostName"),
                Port     = _configurationHelper.GetAppSettingsAsInt("Messaging:Port", 5672)
            };

            return(factory.CreateConnection());
        }
        public StorageService(IConfigurationHelper configurationHelper, IOptions <StorageConfiguration> storageConfiguration)
        {
            Endpoint    = configurationHelper.GetAppSettings("App:Storage:Endpoint");
            AccountName = configurationHelper.GetAppSettings("App:Storage:Name");
            AccountKey  = configurationHelper.GetAppSettings("App:Storage:Key");

            var connectionString = configurationHelper.GetAppSettings("App:Storage:ConnectionString");

            if (string.IsNullOrEmpty(connectionString))
            {
                connectionString = storageConfiguration.Value.StorageConnectionString;
            }

            ConnectionString = connectionString;
        }
Exemple #4
0
        protected string GetCollectionName(IEnumerable <Type> typeHierarchy = null)
        {
            if (typeHierarchy == null)
            {
                typeHierarchy = typeof(TEntity).GetInheritanceHierarchy();
            }

            foreach (var type in typeHierarchy)
            {
                var typeNameCollection = _configurationHelper.GetAppSettings($"MongoTypeMapping:{type.Name}");
                var excludedTypes      = _configurationHelper.GetAppSettingsList("ExcludedMongoTypeMapping");

                if (!string.IsNullOrEmpty(typeNameCollection) && !excludedTypes.Contains(typeNameCollection.ToLower()))
                {
                    return(typeNameCollection);
                }
            }

            return(null);
        }