﻿class Container {
   	
   void SetupSearch (UISearchBar searchBar, UIViewController viewController)
   {
       var searchController = new UISearchDisplayController (searchBar, viewController){
   	Delegate = new MyUISearchDisplayControllerDelegate (this),
   	SearchResultsDataSource = new MyUITableViewDataSource (this),
   	SearchResultsDelegate = new MyUITableViewDelegate (this)
       };
   }
   
   class MyUISearchDisplayControllerDelegate : UISearchDisplayController {
   	Container context;
   	
   	public MyUISearchDisplayControllerDelegate (Container context)
   	{
   		this.context = context;
   	}
   
   	// Methods overwritten here, they use context to reach the container
   }
   
   class MyUITableViewDataSource : UITableViewDataSource {
   	Container context;
   	
   	public MyUITableViewDataSource (Container context)
   	{
   		this.context = context;
   	}
   
   	// Methods overwritten here, they use context to reach the container
   }
   
   class MyUITableViewDelegate : UITableViewDelegate {
   	Container context;
   
   	public MyUITableViewDelegate (Container context)
   	{
   		this.context = context;
   	}
   	// Methods overwritten here, they use context to reach the container
   }
}