예제 #1
0
        public void Rectangle_constructors()
        {
            var ctors = UIConstructorMethods.GetConstructors(typeof(Rectangle));
            var c1    = ctors.Any(p => p.DisplayName == "Rectangle(Double x, Double y, Double width, Double height)");
            var c2    = ctors.Any(p => p.DisplayName == "Rectangle(Point loc, Size sz)");

            Assert.IsTrue(c1, "c1");
            Assert.IsTrue(c2, "c2");
        }
예제 #2
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            if (ctx.Request == null)
            {
                return;
            }

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

            if (req == null)
            {
                return;
            }

            var type = TypeFinder.Find(req.TypeName);

            if (type == null)
            {
                return;
            }

            var ctors = UIConstructorMethods.GetConstructors(type);

            foreach (var ctor in ctors)
            {
                foreach (var p in ctor.Parameters)
                {
                    var pType = TypeFinder.Find(p.TypeName);

                    p.UIType = new UIType
                    {
                        Descriptor = Descriptor.GetDescriptors(pType),
                        FullName   = pType.FullName,
                    };

                    Descriptor.SetPossibleValues(pType, p.UIType);
                }
            }

            ctx.SetResponse <GetConstructorsResponse>(res =>
            {
                var descs = Descriptor.GetDescriptors(type);

                res.Type = new UIType
                {
                    FullName     = req.TypeName,
                    Descriptor   = descs,
                    Constructors = ctors
                };
            });
        }
예제 #3
0
        public void Should_find_structure_constructors()
        {
            var ctors = UIConstructorMethods.GetConstructors(typeof(GridLength));

            var c1 = ctors[0];
            var c2 = ctors[1];

            Assert.AreEqual(2, ctors.Length);
            Assert.AreEqual(typeof(GridLength).AssemblyQualifiedName, c1.TypeName);

            Assert.AreEqual("value", c2.Parameters[0].ParameterName);
            Assert.AreEqual("type", c2.Parameters[1].ParameterName);
            Assert.AreEqual(typeof(GridUnitType).FullName, c2.Parameters[1].TypeName);
        }