Пример #1
0
        public async Task <bool> HasBeenInitializedAsync()
        {
            var requiredInitChecks = new List <Func <Task <bool> > >
            {
                async() =>
                {
                    var existingCollections = (await GetDatabase().ListCollectionNames().ToListAsync()).ToHashSet(StringComparer.OrdinalIgnoreCase);
                    return(CollectionResolver.GetAllNames().All(n => existingCollections.Contains(n)));
                },
                async() =>
                {
                    var existingTeams = (await Team.GetExistingTeamIdsAsync()).ToHashSet();
                    return(Teams.GetAll().Select(t => t.Id).All(id => existingTeams.Contains(id)));
                }
            };

            foreach (var checkFunc in requiredInitChecks)
            {
                if (!await checkFunc())
                {
                    return(false);
                }
            }

            return(true);
        }