Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        public static void WireUpControls(this ILayoutViewHost This, ResolveStrategy resolveMembers = ResolveStrategy.Implicit)
        {
            var members = This.getWireUpMembers(resolveMembers);

            members.ToList().ForEach(m => {
                try {
                    // Find the android control with the same name
                    var view = This.View.getControlInternal(m.PropertyType, m.getResourceName());

                    // Set the activity field's value to the view with that identifier
                    m.SetValue(This, view);
                } catch (Exception ex) {
                    throw new MissingFieldException("Failed to wire up the Property "
                                                    + m.Name + " to a View in your layout with a corresponding identifier", ex);
                }
            });
        }
        /// <summary>
        ///
        /// </summary>
        public static void WireUpControls(this ILayoutViewHost This)
        {
            var members = This.GetType().GetRuntimeProperties()
                          .Where(m => m.PropertyType.IsSubclassOf(typeof(View)));

            members.ToList().ForEach(m => {
                try {
                    // Find the android control with the same name
                    var view = This.View.getControlInternal(m.PropertyType, m.Name);

                    // Set the activity field's value to the view with that identifier
                    m.SetValue(This, view);
                } catch (Exception ex) {
                    throw new MissingFieldException("Failed to wire up the Property "
                                                    + m.Name + " to a View in your layout with a corresponding identifier", ex);
                }
            });
        }
Exemple #3
0
        /// <summary>
        /// Wires a control to a property.
        /// </summary>
        /// <param name="layoutHost">The layout view host.</param>
        /// <param name="resolveMembers">The resolve members.</param>
        public static void WireUpControls(this ILayoutViewHost layoutHost, ResolveStrategy resolveMembers = ResolveStrategy.Implicit)
        {
            var members = layoutHost.GetWireUpMembers(resolveMembers).ToList();

            foreach (var member in members)
            {
                try
                {
                    var view = layoutHost.View.GetControl(layoutHost.GetType().Assembly, member.GetResourceName());
                    member.SetValue(layoutHost, view);
                }
                catch (Exception ex)
                {
                    throw new
                          MissingFieldException("Failed to wire up the Property " + member.Name + " to a View in your layout with a corresponding identifier", ex);
                }
            }
        }