Beispiel #1
0
        public static void Setup(TestContext ctx)
        {
            AssemblyName name = new AssemblyName("JankyUI.Tests");

            _ab = AssemblyBuilder.DefineDynamicAssembly(name, AssemblyBuilderAccess.RunAndSave);
            _mb = _ab.DefineDynamicModule("JankyUI.Tests.NodeHelper", "JankyUI.Tests.Dynamic.dll");

            var dc = new DataContext()
            {
                BindFloatProp  = 123.45f,
                BindFloatField = 678.9f,

                BindIntProp  = 42,
                BindIntField = -42,

                BindEnumProp  = EnumTest.Value1,
                BindEnumField = EnumTest.Value1
            };

            DataContext.BindFloatFieldStatic = 100;
            DataContext.BindFloatPropStatic  = 200;

            _ctx = new JankyNodeContext(dc);
            _ctx.Resources["RES_INT"]       = 13;
            _ctx.Resources["RES_INT_STR"]   = "-37";
            _ctx.Resources["RES_FLOAT"]     = -66.6f;
            _ctx.Resources["RES_FLOAT_STR"] = "-66.6";
            _ctx.Resources["RES_ENUM"]      = EnumTest.value0;
            _ctx.Resources["RES_ENUM_STR"]  = "VaLuE2";
            _ctx.DataContextStack.Begin();
        }
Beispiel #2
0
        public Node Activate(JankyNodeContext context, Dictionary <string, string> initProps)
        {
            var node = (Node)FormatterServices.GetUninitializedObject(NodeType);

            node.Children = new List <Node>();
            node.Context  = context;

            foreach (var kvp in _properties)
            {
                if (initProps == null || !initProps.TryGetValue(kvp.Key, out string value))
                {
                    value = kvp.Value.DefaultValue;
                }
                SetProperty(node, kvp.Key, value);
            }

            NodeType.GetConstructor(Type.EmptyTypes).Invoke(node, null);

            return(node);
        }
Beispiel #3
0
 public Node Activate(JankyNodeContext context)
 {
     return(Activate(context, null));
 }