User Profile
Collapse
-
I did use reflection code :) Thanks -
I meant preceding example
...Code:public abstract class AbstractGenericSingleton<T> where T : AbstractGenericSingleton<T> { private static T _instance; protected static bool Initialised { get { return (_instance != null); } }Leave a comment:
-
"it is only a helper class to avoid writing singleton code multiple times" that is what i wanted to achieve there... yeah now I get Your point with that public property in abstract class, that is correct, thank You for adviceLeave a comment:
-
the thing was I wanted to make an abstract class that its descendants will be instantly Singleton one. That is solution from:
http://www.c-sharpcorner.com/UploadF...Singleton.aspx
My problem has solution:
there it is...
http://social.msdn.microsoft.com/For...4-2476cb64c994
Thank You for Your kind...Leave a comment:
-
By the way... the thing You wrote about
"Method<T> should belong to the abstract class, in which case you need to be able to get an instance of T"
that code:
says itself ( " where T: BaseClass<T>" ) that T must be BaseClass or class that inherits it... so in switch statement we return Class1 or...Code:public BaseClass<T> Method<T>(int z) where T: BaseClass<T>
Leave a comment:
-
You are right there I just noticed that simple skeleton lacked on some things... ok there is whole code:
...Code:public abstract class StorageBaseAbstract<T> where T : StorageBaseAbstract<T> { #region Singleton private static T _instance; protected StorageBaseAbstract() { } protected static bool Initialised { get {Leave a comment:
-
Thank You for response,
Sorry I am newbie here, next time I will use CODE tags. My question concernsmethod how to make it work... Properties cannot be inherited in my solution it is a bit complicated. Is there a way to make that Method<T> work like I wrote it ?...Code:BaseClass<T> Method<T>(int z) where T: BaseClass<T>
Leave a comment:
-
How to return generic abstract class ?
Hi there!
I have something like this:
...Code:abstract class BaseClass<T> { protected BaseClass(){} } class Class1 : BaseClass<Class1> { public static Class1 Instance = new Class1(); private Class1(){} } class Class2 : BaseClass<Class2> { public static Class2
No activity results to display
Show More
Leave a comment: