Reputation: 3187
I am build my custom build process template Argument of type Microsoft.TeamFoundation.Build.Controls.ServerFileBrowserEditor
Since the type is not accessible outside of assembly so i using reflection to create an instance of it.
I wanted to create instance of Microsoft.TeamFoundation.Build.Controls.ServerFileBrowserEditor
because i need to apply filter type filter on it.
How can i create instance of it and show it to user.
Upvotes: 0
Views: 42
Reputation: 4218
As in the comments mentioned, using private types should never be done in a production environment. To create an instance of a private type itself is not a problem:
//reference an accessible type to get the assembly fast and easy
var asm = typeof (Microsoft.TeamFoundation.Build.Controls.AzureEditor).Assembly;
//get the desired type
var type = asm.GetTypes().Single(x => x.Name == "ServerFileBrowserEditor");
//get the constructor
var ctor = type.GetConstructor(Type.EmptyTypes);
//create the object by invoking the constructor
var obj = ctor.Invoke(null);
Upvotes: 1