public static bool Emit(XamlIlEmitContext context, IXamlIlEmitter emitter, XamlIlAstClrProperty property) { if (property is IXamlIlAvaloniaProperty ap) { emitter.Ldsfld(ap.AvaloniaProperty); return(true); } var type = property.DeclaringType; var name = property.Name + "Property"; var found = type.Fields.FirstOrDefault(f => f.IsStatic && f.Name == name); if (found == null) { return(false); } emitter.Ldsfld(found); return(true); }
public static bool Emit(XamlIlEmitContext context, IXamlIlEmitter emitter, IXamlIlProperty property) { var type = (property.Getter ?? property.Setter).DeclaringType; var name = property.Name + "Property"; var found = type.Fields.FirstOrDefault(f => f.IsStatic && f.Name == name); if (found == null) { return(false); } emitter.Ldsfld(found); return(true); }
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); } }
public XamlIlNodeEmitResult Emit(XamlIlEmitContext context, IXamlIlEmitter codeGen) { codeGen.Ldsfld(_field); return(XamlIlNodeEmitResult.Type(0, _field.FieldType)); }