a design question

  • Thread starter Thread starter Zoury
  • Start date Start date
Z

Zoury

Hi! :O)

I making a UserControl which wraps a ListView control (and some others). I'd
like to implement a Fill(object dataSource) method... My question is how can
I support the multiple known data types that can be used as a data source ?
I mean, if the user pass in a string array or a DataTable the code isn't
gonna be the same for both.. So what are the best pratices to do so ?

Thanks!
 
I would overload the Fill() method, this will give you compilation error if
you try to fill with the wrong data.

Fill(DataSet ds)
Fill(DataTable dt)
Fill(IList l)
Fill(IEnumerable e)

etc


It would be near to impossible to accept any datasource, you have to choose
which you want to support.

Chris
 
Hi Chris! :O)
I would overload the Fill() method, this will give you compilation error if
you try to fill with the wrong data.

Yeah i thought of that...
It would be near to impossible to accept any datasource,
you have to choose which you want to support.

Agreed.

Since most of these "datasource Type" implements a goog grasps of interfaces
from the framework, i thought that their might be one (probably more) that
could be handled by the Fill() method instead of coding each one of them
seperatly.. that would also make the code easier to support too...

thanks for your input. ;O)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top