MonoMobile.Views.ViewSource.RowSelected C# (CSharp) Method

RowSelected() public method

public RowSelected ( UITableView tableView, NSIndexPath indexPath ) : void
tableView UITableView
indexPath NSIndexPath
return void
		public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
		{
			tableView.DeselectRow(indexPath, true);

			MemberData memberData = null;

			var listIndexPath = NSIndexPath.FromRowSection(0, indexPath.Section);
			var listSource = GetListSource(listIndexPath);
			
			if (listSource != null && !listSource.IsRootCell)
			{
				var listCount = listSource.Sections[0].DataContext.Count;
				
				if (indexPath.Row < listCount)
				{
					memberData = listSource.MemberData;
									
					if (typeof(IEnumerable).IsAssignableFrom(memberData.Type) || typeof(Enum).IsAssignableFrom(memberData.Type))
					{
						listSource.RowSelected(tableView, indexPath);
						
						// Special case: Since Enums don't have MemberInfo for individual items we only keep track of the base 
						// type and set the actual value based on the row since we display them in the section in value order
						if (typeof(Enum).IsAssignableFrom(memberData.Type))
						{
							memberData.Value = indexPath.Row;
						}

						return;
					}
				}
			}
 
			var cell = Controller.TableView.CellAt(indexPath);
			if (cell == null)
				cell = GetCell(tableView, indexPath);

			foreach(var section in Sections.Values)
			{
				if (section.Views.ContainsKey(cell))
				{
					var views = section.Views[cell];
		
					if (views.Count > 0)
					{
						memberData = GetMemberData(indexPath);
						
						var interceptor = views.Where((view) => (view as ISelectableInterceptor) != null).FirstOrDefault() as ISelectableInterceptor;
						var selectable = views.Where((view) => (view as ISelectable) != null).FirstOrDefault() as ISelectable;
						
						if (interceptor != null)
						{
							interceptor.Preselect(Controller, tableView, memberData, indexPath, selectable);
							interceptor.Postselect(Controller, tableView, memberData, indexPath, selectable);
							break;
						}

						if (selectable != null)
						{
							selectable.Selected(Controller, tableView, memberData, indexPath);
						}
					}
				}
			}
		}