Telling if an entity is abstract

Posts   
 
    
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 19-Jan-2007 21:09:35   

Is there a way to tell if an entity is abstract (in the inheritance sense)?

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 20-Jan-2007 15:42:26   

mikeg22 wrote:

Is there a way to tell if an entity is abstract (in the inheritance sense)?

You mean at runtime? One option is certaily to use reflection.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 20-Jan-2007 16:55:05   

Indeed, and then check the constructor, it should be internal.

Frans Bouma | Lead developer LLBLGen Pro
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 20-Jan-2007 19:28:53   

Otis wrote:

Indeed, and then check the constructor, it should be internal.

I'd like to generate this property into the entity maybe in the entityInclude template. Unfortunately I can't make it shared because you can't override a shared property (which I would want to do in the subclasses of the Abstract supertype). Do you think adding this as a custom entity property in the designer would be the best solution?

Chester
Support Team
Posts: 223
Joined: 15-Jul-2005
# Posted on: 21-Jan-2007 00:09:03   

Actually, because it is shared (static in C#) you don't have to override it. This compiles fine:

    public abstract class FooBar
    {
        public static bool IsAbstract
        {
            get { return true; }
        }

    }

    public class Fooby : FooBar
    {
        public static bool IsAbstract
        {
            get
            {
                return false;
            }
        }
    }
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 21-Jan-2007 02:34:24   

Chester wrote:

Actually, because it is shared (static in C#) you don't have to override it. This compiles fine:

    public abstract class FooBar
    {
        public static bool IsAbstract
        {
            get { return true; }
        }

    }

    public class Fooby : FooBar
    {
        public static bool IsAbstract
        {
            get
            {
                return false;
            }
        }
    }

I had no idea you could do that...thanks! simple_smile