|
-
Mar 12th, 2003, 08:53 AM
#1
Thread Starter
yay gay
(Another) Reflection question?
i have 2 projects and a dll...
the dll is the plugin abstract class im going to inherit from when doing plugins...
one project is the main app and the other project is the plugin.
the plugin project will inherit from the abstract class..and the main app thru reflection will invoke some methods of that class.
the problem is the following: my abstract class, and it's derived classes have its default constructor private and instead they have a one parameter constructor.
As many of the future plugin's will have many classes inside the assembly , when i do the :
Code:
foreach (Type type in types) {
i want to put a "if" to check whenever to use that class(the types that are derived from the plugin dll abstract class are used, the others are ignored) but i am finding the following problem:
to use the .IsSubClassOf() function i must create an instance of the class i want to analise...and the main app only has a reference to the abstract class but i cant create instances of abstract classes. So how would i know if a class from the plugins derivates from the abstract plugin class?
\m/  \m/
-
Mar 12th, 2003, 10:53 AM
#2
Member
This works?
Code:
using System;
using System.Reflection;
public abstract class Vehicle {
public string Make;
public string Model;
static void Main() {
Type t = typeof(Car);
Console.WriteLine(t.IsSubclassOf(typeof(Vehicle)));
}
}
public class Car: Vehicle {}
The IsSubClassOf() method wants a type reference.
-
Mar 12th, 2003, 11:14 AM
#3
Thread Starter
yay gay
no doesnt work because he wants an instantiated class, if i dont instantiate the class he just says that it is a unassigned var
\m/  \m/
-
Mar 12th, 2003, 11:16 AM
#4
Thread Starter
yay gay
AHH! i think i misread (or how it is said) your post! now it is not appointing any kind of error..ill check it out
\m/  \m/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|