private ItemDataBindingsHolder CreateItemDataBindings(UITableViewCell rootView, object itemObject) { ItemDataBindingsHolder itemDataBindings = null; Console.WriteLine("Creating bindings for rootView: " + rootView.ToString()); List <BindingParameters> bindingParametersList; if (ViewDataBindings.RootViewBindingParameters.TryGetValue(rootView, out bindingParametersList)) { Console.WriteLine("Adding list bindings from markup ..."); Type itemType = itemObject.GetType(); itemDataBindings = new ItemDataBindingsHolder(); foreach (var bindingParameter in bindingParametersList) { var viewMemberName = bindingParameter.ViewMemberName; if ((bindingParameter.Mode == BindingMode.OneWay || bindingParameter.Mode == BindingMode.TwoWay) && bindingParameter.UpdateView == null && viewMemberName == null) { var typeName = bindingParameter.View.GetType().FullName; if (!ViewDataBindings.ViewDefaultPropertyOrFieldName.TryGetValue(typeName, out viewMemberName)) { throw new ArgumentException(string.Format("No default property or field name exists for view type {0}. Please specify the name of a property or field in the ViewMemberName binding parameter", typeName), "ViewMemberName"); } } var viewProperty = new PropertyReference(bindingParameter.View, viewMemberName); if (bindingParameter.ViewModelPropertyName == ".") { itemDataBindings.Add(new ItemDataBinding(viewProperty)); } else { var pi = itemType.GetProperty(bindingParameter.ViewModelPropertyName); if (pi != null) { itemDataBindings.Add(new ItemDataBinding(pi, viewProperty)); } else { var fi = itemType.GetField(bindingParameter.ViewModelPropertyName); if (fi != null) { itemDataBindings.Add(new ItemDataBinding(fi, viewProperty)); } } } } } return(itemDataBindings); }
private ItemDataBindingsHolder CreateItemDataBindings(UITableViewCell rootView, object itemObject) { ItemDataBindingsHolder itemDataBindings = null; Console.WriteLine("Creating bindings for rootView: " + rootView.ToString()); List <BindingParameters> bindingParametersList; if (ViewDataBindings.RootViewBindingParameters.TryGetValue(rootView, out bindingParametersList)) { Console.WriteLine("Adding list bindings from markup ..."); Type itemType = itemObject.GetType(); itemDataBindings = new ItemDataBindingsHolder(); foreach (var bindingParameter in bindingParametersList) { var viewMemberName = bindingParameter.ViewMemberName; if ((bindingParameter.Mode == BindingMode.OneWay || bindingParameter.Mode == BindingMode.TwoWay) && bindingParameter.UpdateView == null && viewMemberName == null) { ViewDataBindings.ViewDefaultPropertyOrFieldName.TryGetValue(bindingParameter.View.GetType().FullName, out viewMemberName); } var viewProperty = new PropertyReference(bindingParameter.View, viewMemberName); if (bindingParameter.ViewModelPropertyName == ".") { itemDataBindings.Add(new ItemDataBinding(viewProperty)); } else { var pi = itemType.GetProperty(bindingParameter.ViewModelPropertyName); if (pi != null) { itemDataBindings.Add(new ItemDataBinding(pi, viewProperty)); } else { var fi = itemType.GetField(bindingParameter.ViewModelPropertyName); if (fi != null) { itemDataBindings.Add(new ItemDataBinding(fi, viewProperty)); } } } } } return(itemDataBindings); }
private ItemDataBindingsHolder CreateItemDataBindings(UITableViewCell rootView, object itemObject) { ItemDataBindingsHolder itemDataBindings = null; Console.WriteLine("Creating bindings for rootView: " + rootView.ToString()); List <BindingParameters> bindingParametersList; if (ViewDataBindings.RootViewBindingParameters.TryGetValue(rootView, out bindingParametersList)) { Console.WriteLine("Adding list bindings from markup ..."); Type itemType = itemObject.GetType(); itemDataBindings = new ItemDataBindingsHolder(); foreach (var bindingParameter in bindingParametersList) { if (bindingParameter.PropertyName == ".") { itemDataBindings.Add(new ItemDataBinding(bindingParameter.View)); } else { var pi = itemType.GetProperty(bindingParameter.PropertyName); if (pi != null) { itemDataBindings.Add(new ItemDataBinding(pi, bindingParameter.View)); } else { var fi = itemType.GetField(bindingParameter.PropertyName); if (fi != null) { itemDataBindings.Add(new ItemDataBinding(fi, bindingParameter.View)); } } } } } return(itemDataBindings); }