예제 #1
0
        public async Task <IEnumerable <Configuration> > GetConnections(
            [Service] IConfigurationDatabase database)
        {
            var configDict = await database.ListConfigurations();

            if (!configDict.TryGetValue(Name, out var items))
            {
                return(Enumerable.Empty <Configuration>());
            }
            return(items.Select(o => new Configuration(Name, o)));
        }
예제 #2
0
        public async Task <Configuration?> GetConnection(
            string name,
            [Service] IConfigurationDatabase database)
        {
            var configDict = await database.ListConfigurations();

            if (!configDict.TryGetValue(Name, out var items) || !items.Contains(name))
            {
                return(null);
            }
            return(new Configuration(Name, name));
        }
예제 #3
0
 public async Task <IEnumerable <Connection> > GetConnections(
     [Service] IConfigurationDatabase configurationDatabase)
 => (await configurationDatabase.ListConfigurations())
 .Select(o => new Connection(o.Key, o.Value.Select(value => new Configuration(o.Key, value)).ToList()));