public void InitializeBind(ViewBinding binding, Type modelType, PropertyInfo prop, object model, Context context) { if (ClickBinding != null) { object[] paraVal = null; MethodInfo method = null; object callObj = null; if (ClickBinding.StartsWith("activity:")) { callObj = context; method = context.GetType().GetMethod(ClickBinding.Substring(ClickBinding.IndexOf(":") + 1)); if (method != null) { ParameterInfo[] paras = method.GetParameters(); paraVal = new object[paras.Length]; if (paras.Length > 0) { for (int i = 0; i < paras.Length; i++) { if (paras[i].ParameterType == typeof(Context)) { paraVal[i] = context; } else if (paras[i].ParameterType == typeof(ViewBinding)) { paraVal[i] = binding; } else if (paras[i].ParameterType == modelType) { paraVal[i] = model; } } } } } else { method = modelType.GetMethod(ClickBinding); if (method != null) { ParameterInfo[] paras = method.GetParameters(); paraVal = new object[] { binding }; } } Click += (a, b) => { try { method.Invoke(callObj, paraVal); } catch (Exception ex) { throw new BindingException("Exception on image click: " + ex.InnerException?.Message, ex.InnerException); } }; } }
public BoundImageView(Context context, IAttributeSet attrs) : base(context, attrs) { _context = context; ViewBinding.FillBoundView(this, context, attrs); TypedArray attrArr2 = _context.ObtainStyledAttributes(attrs, Resource.Styleable.BoundButton); ClickBinding = attrArr2.GetString(Resource.Styleable.BoundButton_onclick); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); ViewGroup root = (ViewGroup)Window.DecorView.RootView; ViewGroup root2 = (ViewGroup)root.GetChildAt(0); ViewGroup root3 = (ViewGroup)root2.GetChildAt(0); Binding = new ViewBinding(root3, this, this); }
public BoundConditional(Context context, IAttributeSet attrs) : base(context, attrs) { _context = context; ViewBinding.FillBoundView(this, context, attrs); if (Binding != null && Binding.StartsWith("!")) { Binding = Binding.Substring(1); Inverted = true; } BindValue = attrs.GetAttributeProperty(context, Resource.Styleable.BoundConditional, Resource.Styleable.BoundConditional_bindvalue); }
public void InitializeBind(ViewBinding binding, Type modelType, PropertyInfo prop, object model, Context context) { //TODO: Replace with emit calls for set if (Binding != null) { this.TextChanged += (a, b) => { prop.SetValue(model, (string)this.Text); }; } }
public void InitializeBind(ViewBinding binding, Type modelType, PropertyInfo prop, object model, Context context) { BoundViewItemAttribute attr = prop.GetCustomAttribute <BoundViewItemAttribute>(); if (attr != null) { if (attr.ViewType != null) { InitializeType(attr.ViewType); } else { if (attr.LayoutID == -1) { throw new Exception("No ViewType or layout given in ViewItemAttribute"); } else { InitializeLayout(attr.LayoutID); } } } }
public void InitializeBind(ViewBinding binding, Type modelType, PropertyInfo prop, object model, Context context) { }
public BoundTextView(Context context, IAttributeSet attrs) : base(context, attrs) { _context = context; ViewBinding.FillBoundView(this, context, attrs); }
public void InitializeBinding(object model) { _binding = new ViewBinding(this, model); _initialized = true; }