Example #1
0
        public void store_and_retrieve_by_type()
        {
            var state = new State();
            state.Store<int>(11);
            state.Store<double>(11.1);

            state.Retrieve<int>().ShouldBe(11);
            state.Retrieve<double>().ShouldBe(11.1);
        }
Example #2
0
        public void store_and_retrieve_by_type()
        {
            var state = new State();

            state.Store <int>(11);
            state.Store <double>(11.1);

            state.Retrieve <int>().ShouldBe(11);
            state.Retrieve <double>().ShouldBe(11.1);
        }
Example #3
0
        public void store_and_retrieve_by_type_and_key()
        {
            var state = new State();
            state.Store("red", 11);
            state.Store("green", 12);

            state.Store("red", true);
            state.Store("green", false);

            state.Retrieve<int>("red").ShouldBe(11);
            state.Retrieve<int>("green").ShouldBe(12);

            ShouldBeTestExtensions.ShouldBe(state.Retrieve<bool>("red"), true);
            ShouldBeTestExtensions.ShouldBe(state.Retrieve<bool>("green"), false);
        }
Example #4
0
        public void store_and_retrieve_by_type_and_key()
        {
            var state = new State();

            state.Store("red", 11);
            state.Store("green", 12);

            state.Store("red", true);
            state.Store("green", false);

            state.Retrieve <int>("red").ShouldBe(11);
            state.Retrieve <int>("green").ShouldBe(12);

            ShouldBeTestExtensions.ShouldBe(state.Retrieve <bool>("red"), true);
            ShouldBeTestExtensions.ShouldBe(state.Retrieve <bool>("green"), false);
        }
        public void try_retrieve_by_type_and_key()
        {
            var state = new State();

            state.Store("key1", "value1");

            state.TryRetrieve <string>("key1").ShouldBe("value1");
            state.TryRetrieve <string>("key2").ShouldBeNull();
        }
        public void try_retrieve_by_type()
        {
            var state = new State();

            state.TryRetrieve <int>().ShouldBe(0);

            state.Store(55);

            state.TryRetrieve <int>().ShouldBe(55);
        }
Example #7
0
 static long ReadEntry(Token[] tokens, long offset, State state, uint size, TokenType sep)
 {
     Obj[] entry = new Obj[3];
     offset = ParseEntry(tokens, offset, size, sep, entry);
     if (offset >= 0)
     {
         state.Store(entry, size);
     }
     return(offset);
 }
Example #8
0
        ////////////////////////////////////////////////////////////////////////////////

        static long ReadObj(Token[] tokens, long offset, State state)
        {
            Obj obj;

            offset = ParseObj(tokens, offset, out obj);
            if (offset >= 0)
            {
                state.Store(obj);
            }
            return(offset);
        }
Example #9
0
        ////////////////////////////////////////////////////////////////////////////////

        static long ParseRelTail(Token[] tokens, long offset, uint size, Obj[] firstEntry, bool isMap, out Obj var)
        {
            State state = new State(size);

            state.Store(firstEntry, size);

            TokenParser entryParser;

            if (size == 2)
            {
                if (isMap)
                {
                    entryParser = ReadMapEntry;
                }
                else
                {
                    entryParser = ReadBinRelEntry;
                }
            }
            else
            {
                entryParser = ReadTernRelEntry;
            }

            offset = ReadList(tokens, offset, isMap ? TokenType.Comma : TokenType.Semicolon, TokenType.CloseBracket, entryParser, state);

            if (offset >= 0)
            {
                if (size == 2)
                {
                    var = Builder.CreateBinRel(state.cols[0], state.cols[1]);
                }
                else
                {
                    var = Builder.CreateTernRel(state.cols[0], state.cols[1], state.cols[2]);
                }
            }
            else
            {
                var = null;
            }

            return(offset);
        }
Example #10
0
        static long ReadRecEntry(Token[] tokens, long offset, State state)
        {
            int length = tokens.Length;

            if (offset >= length || tokens[offset].type != TokenType.Symbol)
            {
                return(-offset - 1);
            }
            SymbObj label = (SymbObj)tokens[offset++].value;

            if (offset >= length || tokens[offset].type != TokenType.Colon)
            {
                return(-offset - 1);
            }
            Obj[] entry = new Obj[2];
            offset = ParseObj(tokens, offset + 1, out entry[1]);
            if (offset < 0)
            {
                return(offset);
            }
            entry[0] = label;
            state.Store(entry, 2);
            return(offset);
        }
Example #11
0
        public static void StoreJson(this State state, string json)
        {
            var jobject = JObject.Parse(json);

            state.Store(jobject);
        }