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 IMd Locate(MdLocator location)
        {
            // try find on network
            var key = location.Json();

            if (!_allMds.ContainsKey(key)) // if not found, create with level 0
            {
                var md = InMemoryMd.Create(level: 0);
                _allMds[md.MdLocator.Json()] = md;
                return(md);
            }

            return(_allMds[key]);
        }