how to represent custom class by custom type?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bandzuch martin

    how to represent custom class by custom type?

    hello!
    is there any way how to return custom type for specific class using typeof
    operator?

    //my custom type definition
    class CustomType : System.Type
    {
    ...
    implementation
    ...
    }

    //my custom class
    class CustomClass
    {
    }

    //main somewhere
    Main()
    {
    //this is what i want to do
    CustomType type = typeof( CustomClass );
    }

    this is state where i have stopped, nothing i can figure out
    i have overriden the GetType methods in CustomClass
    class CustomClass
    {
    //static methods
    CustomType GetTypeFromXXX( )
    ...

    //instance methods
    CustomType GetType()
    {
    ...
    }
    }

    but expression typeof( CustomClass ) uses System.Type::Ge tTypeHandle()
    to obtain System.Type for CustomClass.

    what i am trying to do is to set some static relationships for classes.
    examle:

    class Custom1Type : System.Type
    {
    ...
    implementation
    ...

    //static relation with Custom2
    Custom2Type someRelation;
    }

    class Custom1
    {
    }


    class Custom2Type : System.Type
    {
    ...
    implementation
    ...

    //static relation with Custom1
    Custom1Type someRelation1;

    //static relation with Custom3
    Custom3Type someRelation2;
    }

    class Custom2
    {
    }

    class Custom3Type : System.Type
    {
    ...
    implementation
    ...

    //static relation with Custom2
    Custom2Type someRelation;
    }

    class Custom3
    {
    public void Method()
    {
    ...
    }
    }

    Main()
    {
    Custom1Type type1 = typeof( Custom1 );
    type1.someRelat ion.someRelatio n2.InvokeMethod (...);
    }

    thank you for any suggestions, critics or comments.


Working...