|
First thing i'd do if I were you is go and read up on the singleton design pattern. The class you have found/written is for that purpose, and that purpose alone. You may have accidentally stumbled upon a tried-and-tested pattern of software design. Thats usually how you come accross such things and will make you a better programmer.
In answer to your question, you would use the fields/methods of your class as follows - assume the "T" passed in is the class MyClass which has an instance method void Foo() and an instance property int Bar .
Singleton<MyClass> singleton = new Singleton<MyClass>();
singleton.Instance.Foo();
singleton.Instance.Bar = 5
Crucially, you would never access a static property/method on MyClass , only instance properties/methods. Thats by convention of course, as I stated originally there is nothing stopping you referencing a static member, MyClass.StaticProperty
|
|
|
|
|
I will keep that in mind. Many thanks for your patience and help.
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
It looks to me line you're doing something like this[^] and you could use the "new" constraint for that instead of reflection, are you?
|
|
|
|
|
Hi,
Thanks for the reply.
Well I am making use of reference type contraints and in the link they are making use of constructor type contraints, and making use of singleton = new T(); is not permitted when making use of reference type contraints: Cannot create an instance of the variable type 'T' because it does not have the new() constraint.
Either way making use of constructor type contraints does not allow me to gain usage to the other classes's field as in my example.
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
I think you're missing the point of what your Singleton class is for. Did you write it, did someone else write it, or did you get that code snippet from somewhere?
|
|
|
|
|
Hmmm ... OK, I am not trying to achieve a Singleton pattern. I have named my class in such a way that caused alot of confusion ... sorry about that.
Back to the drawing board for me with regards to generics ....
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
see answer above, there's no point posting the same response to me twice!
|
|
|
|
|
Looks like you read[^] this article.
No, only those members that are known to exist for type T are accessible. You only constrained T to class so only members of class are accessible.
If you write an interface IHaveAnExpType, apply it to your class, and then add it as a constraint you would have access to it.
P.S. Dynamic types in C# 4.0 may allow this sort of thing.
|
|
|
|
|
There is cs class that calls native DLL. That class is called from ASP.NET application. How can I step into native DLL while debugging the web project on my computer?
P.S. I can step into the DLL if I run any C# windows project.
Чесноков
|
|
|
|
|
Do not Post the same message twice
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I can very easily extend the glass area of a normal form by calling the DwmExtendFrameIntoClientArea method. However I now have a requirement in which I need an MDI container/parent to have glass extended into the form. If the IsMdiContainer property is set to true, the part that is meant to be glass is white. Anybody have any experience with this issue?
|
|
|
|
|
See here[^] for the answer.
|
|
|
|
|
hi USE THE SAME API AND ADD TWO (ONE ON TOP AND ONE ON LEFT FOR NAVIGATION OR IF YOU JUST NEED ON TOP THEN ONLY ONE WILL WORK) PANELS TO MDIcONTAINER AND GIVE IT BACK COLOR AS bLACK AND IT WILL BE PAINTED AS GLASS BUT IN THE MDI APP YOU WILL LOOS GLASS ON ALL THE CHILD FORMS THATS WHERE I AM RIGHT NOW
|
|
|
|
|
Hi,
i'm in testing with the Process and ProcessStartInfo Classes.
But it doesn't work as aspected.
I want to run another application from my application withe the same rights, i mean with the same user name.
Any suggestions?
My Code:
ProcessStartInfo startinfo = new ProcessStartInfo();
startinfo.FileName = @"C:\Test.exe";
Process.Start( startinfo );
I tried to using the UserName Property, but it doesn't work, because i have to use the password also.
But i dont know the password of the actuall user. (Keyword: terminal Server)
But with the code like the example, the Apllication ist startet as SYSTEM.
Can anybody help me?
|
|
|
|
|
Hi.
How to insert date and time both in one column in oracle sql????
|
|
|
|
|
Do you want to know how to define the field, if so this[^] might be a better place to ask this question.
If you do mean programatically from C# then you really shoud first tell us what you're trying.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
i get time and date in this format
23-JUL-2009 3:38 PM in label.
now i want to save in oracle database in one column, datatype of column in my database is date.
hope u understand my prob.
how i can do this??
thanks in advance
jawad khatri
|
|
|
|
|
INSERT [...] DATE_FIELD = TO_DATE('20090712231538','YYYYMMDDHHNN')
Hard isn't it!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hi
Any body can help me ,i need to get Alert mail in inbox when one perticular News(ex: about Tata steel Ltd.) updated in the world( from all news papers) Like google alert.
and Any body can help me ,i'm not able to find google alert api free download.
Regards,
Ravindar
|
|
|
|
|
|
hi Vilmos, Not like google alert that need to take cred's of google a/c. so i need to download google alert api to integrate into .net application, please send if you have any idea from where we can download freely google alert api.
|
|
|
|
|
afaik it can't be done. The google alert app is doing all the work on the server and just sends the registered e-mail address messages when something comes in. Having the API will allow what? A client coded front end to a web-app.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
ok THANKS and,Please give me idea,if you have any idea how to get google search API to integrate into my application.
|
|
|
|
|
Hi there,
I've built a clientServer chat that each client can send message to all the connected clients, event fired when new client connect or disconnect.
What i'm trying to do now is when a new client connects to the server he will see all the clients that already connected to the chat.
Anybody has an idea how to do this?
Thank,
Tamir
|
|
|
|
|
Do you use a database on server?
If you are using when user connects write a record into a table with clients ip address, and when user disconnects delete that record. In case of client shutdowns a computer without disconnecting server , ping clients from server repeating with a time interval and try to understand if client is still accessable.
|
|
|
|