> I have a singleton-class with private constructor and Instance property.
> It's clear that access to this class should be got by using this property.
> "new Class()" construction is incorrect and throws an error "can't access
> due to its protection level".
It doesn't throw an error - it's a compiler error, so there's no user
code running.
> Is there any opportunity to define custom error when accessing this class
> constructor? E.g. "This class is singleton. Use should use Instance
> property to get its instance"
The best you could do is turn it into a runtime error by making the
constructor public. I don't think that would be an improvement, though.
-- Barry

Signature
http://barrkel.blogspot.com/
Andrey Dzizenko - 12 Jul 2006 09:49 GMT
I've spoken incorrectly. It's a compiler error. I want to redefine a
compiler error.
Making constructor public is bad idea. We can't access to the constructor
directly because of a sigleton.
>> I have a singleton-class with private constructor and Instance property.
>> It's clear that access to this class should be got by using this
[quoted text clipped - 15 lines]
>
> -- Barry
Barry Kelly - 12 Jul 2006 17:01 GMT
> I've spoken incorrectly. It's a compiler error. I want to redefine a
> compiler error.
>
> Making constructor public is bad idea. We can't access to the constructor
> directly because of a sigleton.
I understood you perfectly. You can't create a new compiler error apart
from preprocessor errors like:
#error "Your error message"
but that only works if you want to detect #define conflicts.
-- Barry

Signature
http://barrkel.blogspot.com/