Esempio n. 1
0
        public XamlIlNodeEmitResult Emit(XamlIlEmitContext context, IXamlIlEmitter codeGen)
        {
            context.Emit(Value, codeGen, context.Configuration.WellKnownTypes.Object);
            var t = Type.GetClrType();

            if (t.IsValueType)
            {
                codeGen.Unbox_Any(t);
            }
            else
            {
                codeGen.Castclass(t);
            }
            return(XamlIlNodeEmitResult.Type(0, t));
        }
Esempio n. 2
0
                public void EmitCall(IXamlIlEmitter emitter)
                {
                    var method = Parent._avaloniaObject
                                 .FindMethod(m => m.IsPublic && !m.IsStatic && m.Name == "GetValue"
                                             &&
                                             m.Parameters.Count == 1 &&
                                             m.Parameters[0].Equals(Parent._avaloniaPropertyType));

                    if (method == null)
                    {
                        throw new XamlIlTypeSystemException(
                                  "Unable to find T GetValue<T>(AvaloniaProperty<T>) on AvaloniaObject");
                    }
                    emitter
                    .Ldsfld(Parent._field)
                    .EmitCall(method);
                    if (Parent.PropertyType.IsValueType)
                    {
                        emitter.Unbox_Any(Parent.PropertyType);
                    }
                }