Possible Duplicate:
using c# reflection to call a constructor
How to call the constructor of a class from a string variable?
In PHP I can do this:
$myclassName = '\Namespace\MyClass';
$myParameters = array ('param1', 'param2');
$reflection = new \ReflectionClass($myclassName );
$myClassInstance = $reflection->newInstanceArgs($myParameters);
As I can do in C #?
i have a list o views like
- PersonView
- HouseView
- CarView
and her ViewModel
- PersonViewModel
- HouseViewModel
- CarViewModel
I have one ObservableCollection in my code i dont wana add a new Command for each kind
AddPersonView = new RelayCommand(() =>
{
//code
});
AddCarView = new RelayCommand(() =>
{
//code
});
//etc
i wanna pass CommandParameter to the same Command
AddView = new RelayCommand((name) =>
{
// pseudo code
var o = CreateIntance(name + "View");
o.DataContext = CreateIntance(name + "ViewModel");
_observableList.Add(o);
// end
});