Exemplo n.º 1
0
        public bool BindViewProperty(object view, string viewProperty, BaseObservable bindable, string bindableProperty, BindMode bindMode)
        {
            if (view == null)
            {
                return(false);
            }
            if (string.IsNullOrEmpty(viewProperty))
            {
                return(false);
            }
            if (bindable == null)
            {
                return(false);
            }
            if (string.IsNullOrEmpty(bindableProperty))
            {
                return(false);
            }

            var vProp = view.GetType().GetProperty(viewProperty);

            if (vProp == null)
            {
                return(false);
            }
            var bProp = bindable.GetType().GetProperty(bindableProperty);

            if (bProp == null)
            {
                return(false);
            }

            //if (!bProp.PropertyType.Equals(typeof(T)) && !bProp.PropertyType.IsSubclassOf(typeof(T)))
            //  return false;

            string cViewPropID = string.Concat(view.GetType().Name, view.GetHashCode(), viewProperty);

            if (ObjectLinks.ContainsKey(cViewPropID))
            {
                return(false);
            }

            string cObjectPropID = string.Concat(bindable.GetType().Name, bindable.GetHashCode(), bindableProperty);

            ObjectLinks.Add(cViewPropID, new ObjectLink {
                ID = cObjectPropID, Object = bindable, Property = bProp
            });
            BindModes.Add(cViewPropID, bindMode);


            ViewLinks.Add(new KeyValuePair <string, ViewLink>(cObjectPropID, new ViewLink {
                ID = cViewPropID, View = view, Property = vProp
            }));

            if (!ObservedObjects.Contains(bindable))
            {
                ObservedObjects.Add(bindable);
            }

            return(true);
        }
Exemplo n.º 2
0
 public void Dispose()
 {
     Object   = null;
     Property = null;
 }
Exemplo n.º 3
0
 public bool BindViewProperty(int viewID, string viewProperty, BaseObservable bindable, string bindableProperty, BindMode bindMode = BindMode.OneWay)
 {
     return(BindViewProperty(RootView.FindViewById(viewID), viewProperty, bindable, bindableProperty, bindMode));
 }