예제 #1
0
    private void loadJson()
    {
        Inventory inventory = new Inventory();

        JsonInterpreter.getDataFromJson <Inventory>(ref inventory, JsonInterpreter.getJsonFromFile("inventory"));
        if (null != inventory)
        {
            //create all dynamic slot
            foreach (Item item in inventory.items)
            {
                //instantiate slot
                GameObject SlotInstance = Instantiate(SlotPrefab);

                //update the item component
                ItemBehavior itemComponent = SlotInstance.GetComponent <ItemBehavior>();
                if (itemComponent)
                {
                    itemComponent.init(item);
                }

                //add to the grid
                SlotInstance.transform.SetParent(this.transform);
            }
        }
    }
        public string Post([FromBody] JsonInterpreter JsonData)
        {
            Interpreter MyInterpreter = new Interpreter(JsonData);

            MyInterpreter.Run();
            return("Is ok");
        }
예제 #3
0
        public void JsonInterpreter_test()
        {
            IConfigurationStore store = new DefaultConfigurationStore();
            string    uri             = "SqlMap.config.Json";
            IResource resource        = ResourceLoaderRegistry.GetResource(uri);

            IConfigurationInterpreter interpreter = new JsonInterpreter(resource);

            interpreter.ProcessResource(store);
        }
    private void loadJson()
    {
        Inventory inventory = new Inventory();

        JsonInterpreter.getDataFromJson <Inventory>(ref inventory, JsonInterpreter.getJsonFromFile("inventory"));
        if (null != inventory)
        {
            Debug.Log(inventory.items.Length);
        }
    }
    private void generateJson()
    {
        //simulate content
        Item[] items =
        {
            new Item(1, "Potion", 6),
            new Item(2, "Ether",  3),
            new Item(3, "Boots",  1),
            new Item(4, "Sword",  5),
        };
        Inventory inventory = new Inventory(items);

        Debug.LogWarning(JsonInterpreter.getJsonWithEntity <Inventory>(inventory));
    }
예제 #6
0
        public IInterpreter LoadSimpleJson(string filename)
        {
            var jsonResource = new JsonInterpreter(null)
            {
                Stubs = new List <IStubDefinition>()
            };

            var fileraw = File.ReadAllText(filename);

            var jsonRoot = Newtonsoft.Json.JsonConvert.DeserializeObject <RootObject>(fileraw);

            jsonRoot.defs.ForEach(def =>
            {
                var rootUrl = def.root;
            });


            return(jsonResource);
        }
        private static object Compile(string script)
        {
            var program = JintEngine.ParseProgram(script);

            if (program == null)
                return JsUndefined.Instance;

            var typeSystem = new TypeSystem();
            var scriptBuilder = typeSystem.CreateScriptBuilder(null);
            var bindingVisitor = new BindingVisitor(scriptBuilder);

            program.Accept(bindingVisitor);

            var boundProgram = bindingVisitor.Program;

            var interpreter = new JsonInterpreter(new JintEngine().Global);
            if (boundProgram.Body.Accept(interpreter))
                return interpreter.Result;

            return null;
        }
예제 #8
0
        private CompilationResult CompileProgram(string script, string fileName)
        {
            ProgramSyntax program;

            #if !DEBUG
            try
            {
            #endif
                program = ParseProgram(script);

                if (program == null)
                    return new CompilationResult(JsNull.Instance, null);
            #if !DEBUG
            }
            catch (Exception e)
            {
                throw new JsException(JsErrorType.SyntaxError, e.Message);
            }
            #endif

            var scriptBuilder = TypeSystem.CreateScriptBuilder(fileName);
            var bindingVisitor = new BindingVisitor(scriptBuilder);

            program.Accept(bindingVisitor);

            var boundProgram = bindingVisitor.Program;

            var interpreter = new JsonInterpreter(Global);
            if (boundProgram.Body.Accept(interpreter))
                return new CompilationResult(interpreter.Result, null);

            var resultExpressions = DefiniteAssignmentPhase.Perform(boundProgram);
            boundProgram = ResultRewriterPhase.Perform(boundProgram, resultExpressions);
            TypeMarkerPhase.Perform(boundProgram);

            boundProgram = SquelchPhase.Perform(boundProgram);

            PrintBound(boundProgram);

            EnsureGlobalsDeclared(boundProgram);

            var main = new CodeGenerator(Global, scriptBuilder).BuildMainMethod(boundProgram);

            return new CompilationResult(null, main);
        }