Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Anything
- {
- public int Data { get; set;}
- }
- public class MyGenericBase<T>
- {
- public void InstanceMethod(T data)
- {
- // do some job
- }
- public static void StaticMethod(T data)
- {
- // do some job
- }
- // others members...
- }
- public sealed class UsefulController : MyGenericBase<Anything>
- {
- public void ProxyToStaticMethod()
- {
- StaticMethod(null);
- }
- // others non derived members...
- }
- public class Container
- {
- public UsefulController B { get; set; }
- }
- public class Demo
- {
- public static void Test()
- {
- var c = new Container();
- c.B.InstanceMethod(null); // Works as expected.
- c.B.StaticMethod(null); // Doesn't work.
- // Static method call on object rather than type.
- // How to get the static method on the base type ?
- c.B.ProxyToStaticMethod(); // Works as expected.
- }
- }
- public class GenericBase<T> : MyGenericBase<T>
- {
- // Create instance calls here for every base static method.
- }
- public sealed class UsefulController : GenericBase<Anything>
- {
- // others non derived members...
- }
- MyGenericBase<Anything>.StaticMethod( null );
- UsefulController.StaticMethod(null);
- MyGenericBase<Anything>.StaticMethod(null);
Add Comment
Please, Sign In to add comment