Exemplo n.º 1
0
        public void Construct_GridLength_single_numeric_parameter_ctor()
        {
            var tf = new TypeFinder();

            var ctor = new UIConstructor
            {
                TypeName   = typeof(GridLength).AssemblyQualifiedName,
                Parameters = new[]
                {
                    new UIParameter
                    {
                        TypeName      = "System.Double",
                        ParameterName = "value",
                        Position      = 0,
                        Value         = 5
                    }
                }
            };

            var obj    = UIConstructorMethods.Construct(tf, ctor);
            var casted = (GridLength)obj;

            Assert.AreEqual(5, casted.Value);
            Assert.AreEqual(GridUnitType.Absolute, casted.GridUnitType);
        }
Exemplo n.º 2
0
        public void Construct_GridLength_two_parameter_ctors_one_isenum()
        {
            var tf = new TypeFinder();

            var ctor = new UIConstructor
            {
                TypeName   = typeof(GridLength).AssemblyQualifiedName,
                Parameters = new[]
                {
                    new UIParameter
                    {
                        TypeName      = "System.Double",
                        ParameterName = "value",
                        Position      = 0,
                        Value         = 7
                    },
                    new UIParameter
                    {
                        TypeName      = typeof(GridUnitType).FullName,
                        ParameterName = "type",
                        Position      = 1,
                        Value         = GridUnitType.Star
                    }
                }
            };

            var obj    = UIConstructorMethods.Construct(tf, ctor);
            var casted = (GridLength)obj;

            Assert.AreEqual(7, casted.Value);
            Assert.AreEqual(GridUnitType.Star, casted.GridUnitType);
        }
Exemplo n.º 3
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            if (ctx.Request == null)
            {
                return;
            }

            var req = ctx.Get <CallConstructorRequest>();

            if (req == null)
            {
                return;
            }

            var error   = string.Empty;
            var success = false;
            var obj     = UIConstructorMethods.Construct(TypeFinder, req.Constructor);

            if (obj != null)
            {
                try
                {
                    SetPropertyValue(req.WidgetId, req.Property.Path, obj, false, false);
                }
                catch (Exception ex)
                {
                    error   = ex.ToString();
                    success = false;
                }

                success = true;
            }

            ctx.SetResponse <CallConstructorResponse>(res =>
            {
                res.ErrorMessage = error;
                res.Successful   = success;
            });
        }