Ejemplo n.º 1
0
        public static async Task <Result <IDatabase> > GetOrAddAsync(MdHead mdHead, IIndexer indexer)
        {
            var typeInfo = await TypeStoreFactory.GetOrAddTypeStoreAsync(mdHead.Md).ConfigureAwait(false);

            var db = new Database(/*mdHead.Md, */ typeInfo, indexer);

            var typeStores = await typeInfo.GetAllAsync().ConfigureAwait(false);

            db._dataTreeAddresses = typeStores
                                    .ToDictionary(c => c.Item1, c => c.Item2);

            return(Result.OK((IDatabase)db));
        }
Ejemplo n.º 2
0
        public static async Task <Indexer> GetOrAddAsync(MdHead mdHead)
        {
            var typeStore = await TypeStoreFactory
                            .GetOrAddTypeStoreAsync(mdHead.Md)
                            .ConfigureAwait(false);

            var indexer = new Indexer(/*mdHead.Md, */ typeStore);

            var typeStores = await typeStore.GetAllAsync()
                             .ConfigureAwait(false);

            indexer._dataTreeAddresses = typeStores
                                         .ToDictionary(c => c.Item1, c => c.Item2);

            indexer._paths = new ConcurrentDictionary <string, string[]>(indexer._dataTreeAddresses
                                                                         .Where(c => c.Key.Count(t => t == '/') == 2) // ayy.. must be better than this
                                                                         .ToDictionary(c => c.Key, c => c.Key.Split('/')[1].Split('.')));

            return(indexer);
        }