Click here to Skip to main content
15,921,371 members
Home / Discussions / C#
   

C#

 
GeneralBut my Image is Non-Rectangular Pin
Sukhjinder_K13-Dec-07 22:11
Sukhjinder_K13-Dec-07 22:11 
GeneralGraphicsPaths and Scrolling Pin
DahrkDaiz12-Dec-07 5:38
DahrkDaiz12-Dec-07 5:38 
GeneralRe: GraphicsPaths and Scrolling Pin
Paul Conrad23-Dec-07 9:57
professionalPaul Conrad23-Dec-07 9:57 
GeneralCell phones application using c#.net Pin
mostafa_h12-Dec-07 5:26
mostafa_h12-Dec-07 5:26 
GeneralRe: Cell phones application using c#.net Pin
Sathesh Sakthivel12-Dec-07 6:57
Sathesh Sakthivel12-Dec-07 6:57 
GeneralRe: Cell phones application using c#.net Pin
mostafa_h12-Dec-07 9:49
mostafa_h12-Dec-07 9:49 
Generalc# event log size Pin
oi12-Dec-07 5:19
oi12-Dec-07 5:19 
GeneralDynamically instantiating a type and validating interface implementation Pin
Le centriste12-Dec-07 4:49
Le centriste12-Dec-07 4:49 
Hi all

I have a framework that define few interfaces. The types implementing those interfaces are not known before runtime, and are instantiated using the System.Type class and the System.Reflection namespace.

I want to have your take on the best way to do this:

- Instantiating the class (using a default constructor).
- Verifying the type is an instantiable reference type (currently I use Type.IsClass and Type.IsAbstract properties).
- and, finally, the most tricky part, verifying that a particular interface is implemented by the type. Currently, I use:

if (!(typeinstance is IMyInterface)) { throw new Exception(); }

Would you recommend a different approach? I ask this because I would like to standardize a way that multiple projects could use a framework where you pass a type definition string and an interface type that this type has to implement. The method would return an instance of the interface or throw an exception if the type cannot be instantiated using Type.GetType(string, bool) for instance, is not instantiable (abstract class, for instance), or does not implement the interface.

Thank you.

-----

You seem eager to impose your preference of preventing others from imposing their preferences on others. -- Red Stateler, Master of Circular Reasoning and other fallacies

If atheism is a religion, then not collecting stamps is a hobby. -- Unknown

God is the only being who, to rule, does not need to exist. -- Charles Baudelaire

GeneralRe: Dynamically instantiating a type and validating interface implementation Pin
led mike12-Dec-07 5:11
led mike12-Dec-07 5:11 
GeneralRe: Dynamically instantiating a type and validating interface implementation Pin
m@u12-Dec-07 5:22
m@u12-Dec-07 5:22 
GeneralRe: Dynamically instantiating a type and validating interface implementation Pin
Le centriste12-Dec-07 5:54
Le centriste12-Dec-07 5:54 
Generaldeclaring form Pin
arkiboys12-Dec-07 4:35
arkiboys12-Dec-07 4:35 
GeneralRe: declaring form Pin
Kristian Sixhøj12-Dec-07 5:31
Kristian Sixhøj12-Dec-07 5:31 
GeneralRe: declaring form Pin
arkiboys12-Dec-07 5:50
arkiboys12-Dec-07 5:50 
GeneralRe: declaring form Pin
Kristian Sixhøj12-Dec-07 6:47
Kristian Sixhøj12-Dec-07 6:47 
GeneralRe: declaring form Pin
Sathesh Sakthivel12-Dec-07 6:58
Sathesh Sakthivel12-Dec-07 6:58 
GeneralRe: declaring form Pin
Luc Pattyn12-Dec-07 7:31
sitebuilderLuc Pattyn12-Dec-07 7:31 
QuestionCan radio button text be set at left instead of right Pin
MANOJ BATRA12-Dec-07 4:28
MANOJ BATRA12-Dec-07 4:28 
AnswerRe: Can radio button text be set at left instead of right Pin
c0ax_lx12-Dec-07 5:20
c0ax_lx12-Dec-07 5:20 
QuestionHow to change panel and form border color at design time Pin
MANOJ BATRA12-Dec-07 4:11
MANOJ BATRA12-Dec-07 4:11 
QuestionHow to get all ButtonItem in RibbonControl of DevComponents.DotNetBar Pin
RockPhoenix12-Dec-07 2:57
RockPhoenix12-Dec-07 2:57 
GeneralSerializaion and XML Serialization issue Pin
manustone12-Dec-07 1:45
manustone12-Dec-07 1:45 
GeneralRe: Serializaion and XML Serialization issue Pin
TJoe12-Dec-07 4:12
TJoe12-Dec-07 4:12 
GeneralRe: Serializaion and XML Serialization issue Pin
Skippums12-Dec-07 5:52
Skippums12-Dec-07 5:52 
GeneralCross Thread Calls Pin
MicealG12-Dec-07 0:55
MicealG12-Dec-07 0:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.