MonoMobile.Views.ViewParser.CheckForNavbarItems C# (CSharp) Method

CheckForNavbarItems() public method

public CheckForNavbarItems ( object view ) : List
view object
return List
		public List<CommandBarButtonItem> CheckForNavbarItems(object view)
		{
			var buttonList = new List<CommandBarButtonItem>();
			var members = GetMethods(view);
			foreach(var member in members)
			{
				var buttonAttribute = member.GetCustomAttribute<NavbarButtonAttribute>();
				var captionAttribute = member.GetCustomAttribute<CaptionAttribute>();
				var caption = captionAttribute != null ? captionAttribute.Caption : null;
				
				if (buttonAttribute != null)
				{
					var memberName = buttonAttribute.ButtonType.HasValue ? null : member.Name.Capitalize();

					var title = caption ?? memberName;

					if (buttonAttribute.CellViewType != null)
					{	
						UIView buttonView = Activator.CreateInstance(buttonAttribute.CellViewType) as UIView;
						
						CheckForInstanceProperties(view, member, buttonView);

						var tappable = buttonView as ICommandButton;
						if (tappable != null)
						{
							tappable.Command = GetCommandForMember(view, member); 
							tappable.Command.CanExecuteChanged += HandleCanExecuteChanged;
						}
					}

					var button = CreateCommandBarButton(view, member, title, null, buttonAttribute.Style, buttonAttribute.ButtonType, buttonAttribute.Location);
					
					if (button != null)
					{
						if (button.Command != null)
						{
							button.Command.CanExecuteChanged += HandleCanExecuteChanged;
						}

						buttonList.Add(button);
					}
				}
			}
			
			if (buttonList.Count > 0)
			{
				var sortedList = buttonList.OrderBy(button=>button.Tag).ToList();
				return sortedList;
			}	

			return null;
		}