コード例 #1
0
        Result <Pointer> ExpandLevel(string key, StoredValue value)
        {
            if (Level == 0)
            {
                return(new ArgumentOutOfRange <Pointer>(nameof(Level)));
            }

            var md          = InMemoryMd.Create(Level - 1);
            var leafPointer = (md as InMemoryMd).Add(key, value);

            if (!leafPointer.HasValue)
            {
                return(leafPointer);
            }

            switch (md.Type)
            {
            case MdType.Pointers:     // i.e. we have still not reached the end of the tree
                Add(new Pointer
                {
                    MdLocator = md.MdLocator,
                    ValueType = typeof(Pointer).Name
                });
                break;

            case MdType.Values:     // i.e. we are now right above leaf level
                Add(leafPointer.Value);
                break;

            default:
                return(new ArgumentOutOfRange <Pointer>(nameof(md.Type)));
            }

            return(leafPointer);
        }
コード例 #2
0
 public static void UseInMemoryDb()
 {
     SetCreator(level => Task.FromResult(InMemoryMd.Create(level)));
     SetLocator(location => Task.FromResult(Result.OK(InMemoryMd.Locate(location))));
 }