GetCommandForMember() public static méthode

public static GetCommandForMember ( object view, MemberInfo member ) : ReflectiveCommand
view object
member System.Reflection.MemberInfo
Résultat ReflectiveCommand
Exemple #1
0
        protected virtual void Prepare()
        {
            CommandMap.Clear();

            _ActualActionSheet            = new UIActionSheet(Title);
            _ActualActionSheet.Dismissed += HandleDismissed;

            var methods = GetType().GetMethods().Where((methodInfo) => methodInfo.GetCustomAttribute <ButtonAttribute>(true) != null).ToList();

            ICommand command       = null;
            var      destroyMethod = methods.Where((methodInfo) => methodInfo.Name == "Destroy").SingleOrDefault();

            if (destroyMethod != null)
            {
                command = ViewParser.GetCommandForMember(this, destroyMethod);
                var destroyIndex = AddButtonToSheet(GetTitle(destroyMethod), command);
                if (destroyIndex > -1)
                {
                    _ActualActionSheet.DestructiveButtonIndex = destroyIndex;
                }
            }

            foreach (var method in methods)
            {
                if (method.Name != "Cancel" && method.Name != "Destroy")
                {
                    command = ViewParser.GetCommandForMember(this, method);
                    AddButtonToSheet(GetTitle(method), command);
                }
            }

            var cancelMethod = methods.Where((methodInfo) => methodInfo.Name == "Cancel").SingleOrDefault();

            if (cancelMethod != null)
            {
                command = ViewParser.GetCommandForMember(this, cancelMethod);
                var cancelIndex = AddButtonToSheet(GetTitle(cancelMethod), command);
                if (cancelIndex > -1)
                {
                    _ActualActionSheet.CancelButtonIndex = cancelIndex;
                }
            }
        }
Exemple #2
0
        private void ConfigureRowEditing()
        {
            if (Controller != null && Controller.RootView != null)
            {
                var cellEditingStyle = Controller.RootView.GetType().GetCustomAttribute <CellEditingStyleAttribute>();
                if (cellEditingStyle == null)
                {
                    if (MemberData != null)
                    {
                        cellEditingStyle = MemberData.Member.GetCustomAttribute <CellEditingStyleAttribute>();
                    }
                }

                if (cellEditingStyle != null)
                {
                    _EditingStyle  = cellEditingStyle.EditingStyle;
                    _CanEditSource = Controller.RootView;
                    _CanEditMember = GetMemberFromView(cellEditingStyle.CanEditMemberName);
                    if (_CanEditMember == null)
                    {
                        _CanEditMember = GetMemberFromViewModel(cellEditingStyle.CanEditMemberName);

                        var dc = Controller.RootView as IDataContext <object>;
                        if (dc != null && dc.DataContext != null)
                        {
                            _CanEditSource = dc.DataContext;
                        }
                    }

                    if (!string.IsNullOrEmpty(cellEditingStyle.EditCommandMemberName))
                    {
                        var commandMember = _CanEditSource.GetType().GetMember(cellEditingStyle.EditCommandMemberName).FirstOrDefault();
                        if (commandMember != null)
                        {
                            _EditCommand = ViewParser.GetCommandForMember(_CanEditSource, commandMember);
                        }
                    }
                }
            }
        }