Exemple #1
0
        public static void test6()
        {
            var builder = new FoClass("FoComponent");
            var root    = builder.ConstructInstanceCore("") as FoComponent;

            IFoProperty[] props1 =
            {
                new FoProperty <string>("proper name", "Stephen R. Strong"),
            };

            IFoProperty[] props2 =
            {
                new FoProperty <double>("tax",   .33),
                new FoProperty <double>("total", () => { return(1000); })
            };


            root.Properties.AddList(props1);

            IFoComponent[] comps =
            {
                new FoComponent("Comp1", props2),
            };

            root.Subcomponents.AddList(comps);
            var comp = comps[0] as FoComponent;

            Console.WriteLine($"===========================");
            Console.WriteLine($"{root.AsJson()}");
            Console.WriteLine($"{comp.AsJson()}");
            root.saveToFile(@"data/test6.json");
            Console.WriteLine($"..........................");
        }
Exemple #2
0
        public static void test1()
        {
            var builder = new FoClass("FoComponent");
            var root    = builder.ConstructInstanceCore("") as FoComponent;

            IFoProperty[] props =
            {
                new FoProperty <double>("width",  100),
                new FoProperty <double>("height", .33),
                new FoProperty <double>("area",   () => {
                    var width  = new FoReference("width");
                    var height = new FoReference("height");
                    var area   = width.GetValue <double>(root) * height.GetValue <double>(root);
                    return(area);
                })
            };
            root.Properties.AddList(props);


            //var root = new FoComponent("Comp1", props);

            Console.WriteLine($"===========================");
            Console.WriteLine($"{root.AsJson()}");
            Console.WriteLine($"..........................");
        }
Exemple #3
0
        public static void test5()
        {
            var path = "C:\\Users\\Steve\\workspace\\FoundryDotNet5\\FoundryCore\\data\\create_root.json";
            var body = JSONExtensions.readFromFile(path);
            //var body = JSONExtensions.readFromFile(@"data/create_root.json");

            var name = body.GetProperty("MyName").ToString();
            var type = body.GetProperty("MyType").ToString();

            var builder = new FoClass(type);
            var root    = builder.ConstructInstanceCore("");


            Console.WriteLine($"===========================");
            Console.WriteLine($"{root.toJson()}");
            Console.WriteLine($"{root.AsJson()}");
            root.saveToFile(@"data/test5.json");
            Console.WriteLine($"..........................");
        }