Exemplo n.º 1
0
        public async Task <Result <Pointer> > UpdateAsync(string type, MdLocator location)
        {
            var(pointer, value) = (await _dataTree.GetAllPointerValuesAsync().ConfigureAwait(false))
                                  .Single(c => c.Item1.MdKey == type);
            var mdResult = await MdAccess.LocateAsync(pointer.MdLocator).ConfigureAwait(false);

            if (!mdResult.HasValue)
            {
                return(Result.Fail <Pointer>(mdResult.ErrorCode.Value, mdResult.ErrorMsg));
            }
            value.Payload = location.Json();
            return(await mdResult.Value.SetAsync(type, value).ConfigureAwait(false));
        }
Exemplo n.º 2
0
        public static IMdNode Locate(MdLocator locator)
        {
            // try find on network
            var key = locator.Json();

            if (!_allMds.ContainsKey(key))
            {
                // if not found, create with level 0
                var newMd = new InMemoryMd(locator, 0);
                _allMds[key] = newMd;
                return(newMd);
            }

            return(_allMds[key]);
        }