|
static functions are generally a bad idea, it presumes how your class will be used.
you are better off using a seperate help classer - see design patterns, GOF - "prefer composition to inheritance" (or something like that).
Personally I think Serialization sucks - have a look a the memento pattern...
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Cromwell wrote:
What do you do leppie? You have amazing response times - not that I'm complaining.
I'm jobless hovering on a free GPRS connection
Like in the post before mine, I would suggest making a helper class to take care of the static methods This could even be the abstract baseclass for all types of chalk, and the base class would implement IChalk. Else, cant static IChalk Deserialize( string Xml ) become non static, because adding a static member there does not make sense...
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
leppie wrote:
Else, cant static IChalk Deserialize( string Xml ) become non static, because adding a static member there does not make sense
actually that was my argument. I think it doesn't make sense to not have it static. If it isn't static you have just instanciated two IChalk objects by returning an IChalk object. Also, as I mentioned, if you use the Deserialize as a member that updates/sets the values of the object. You have an invalid IChalk object between the point of instanciation and the Deserialization call. Granted it will be most common that the Deserialization call be made directly following the instanciate or, at least before the object is used, but a solid class wouldn't leave that moment of possibility open. Also, its possible that the deserialization method implemented by some other because they need the IChalk interface wouldn't do a good job of guaranteeing that the class is valid after deserialization. Ie deserialize may very well leave IChalk.color = null when that isn't acceptable because it wasn't specified in the serialized xml. Get my point. I see and realize there are ways of doing things (ie, abstract classes+interfaces, presume good implementation (;/), etc, but I'm a pain in the arse.
|
|
|
|
|
Cromwell wrote:
If it isn't static you have just instanciated two IChalk objects by returning an IChalk object.
You would have to instanciated an IChalk object to use an IChalk object. Remember the type of the IChalk object will not be IChalk, it will be the actuall type of the class
I think we should look back at the definition of an interface and if they really needed in your case. From what I can see, a base class with some abstract methods (those you would use with the original interface) will provided the best solution in your case and it would pretty much function the same.
From MSDN:
An interface:
An interface defines a contract. A class or struct that implements an interface must adhere to its contract. An interface may inherit from multiple base interfaces, and a class or struct may implement multiple interfaces.
Interfaces can contain methods, properties, events, and indexers. The interface itself does not provide implementations for the members that it defines. The interface merely specifies the members that must be supplied by classes or interfaces that implement the interface.
An abstract class:
When a non-abstract class is derived from an abstract class, the non-abstract class must include actual implementations of all inherited abstract members. Such implementations are provided by overriding the abstract members.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
leppie wrote:
You would have to instanciated an IChalk object to use an IChalk object. Remember the type of the IChalk object will not be IChalk, it will be the actuall type of the class
His point (and a good one) is that he shouldn't have needed to instantiate any object that implements IChalk in order to call Deserialize, by itself Deserialize doesn't need any state at all to operate (since it only creates a new instance of that object and returns a reference as the interface).
I think the class factory pattern would apply well here, have a class/interface that deserializes and creates new instances of objects implementing IChalk.
interface IChalkFactory
{
IChalk Deserialize();
IChalk Create();
void Serialize(IChalk);
} James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Tanka! Maybe your explaination made more sense than mine did. I have to say the inability to add static members to an interface is quite irritating. Ugh...
So many missing pieces...
|
|
|
|
|
Hi,
I have installed the Enterprise developer version after
uninstalling the beta version of Visual Studio .NET.
The problem is that now I can't execute any application
from the Begin button, neither debugging step by step; it
doesn't matter either the size and number of forms of the
project. In all cases when the form should be shown the
IDE hangs up like if the window shown was disabled. I can
close the application process and the IDE seems to recover
but keeps on hanged up. At the and I must close de IDE
process.
I uninstalled SourceSafe (I installed VS.NET & SourceSafe
at the same time) but nothing changed.
Does anyone knows what is happening and why?, any similar
problem?
Thanks in advance,
Edgar
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
|
Does it just sit there doing nothing or is it really hung (ie responds to nothing)?
For me in about 15 of 100 runs it will stop execution after loading System.Drawing.dll
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
well - im not 100% sure, after a long time the debug bar appears, but still the app does not show, so I just end the process for the app, and the IDE returns to normal.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
.NET service pack 2.
And I swallow a small raisin.
|
|
|
|
|
Thanks for your reply.
I have already installed it on my computer but keeps on hanging up...
Any other suggestion?
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
|
I had problems with SmartHelp and IDE, dunno if this is related.
Format is allways a solution
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
this is a known problem with vs 7.0, it is not fixed in sp1 pr sp2, there are steps to help the problem but to be honest i can't remember what they are (sorry).
if you post your problems to the microsoft.public.dotnet.languages.csharp newsgroup you will get a lot of help there.
I get it about 4 times out of 10, but I get usually get it to work by clicking the restart toolbar button.
I vaguely remember it also helps if you don't use your system to host a web dev stuff (asp), stopping some of the services on your machine to do with this helps, although it never fixed mine as I don't use the machine for asp stuff.
There is also some stuff on msdn/technet aboput the problem as well.
sorry I couldn't be of much help.
bg
|
|
|
|
|
Our group has encountered the same problem. We have found two things that will "un-hang" the IDE.
1. Disconnect your network connection (I have created a short-cut to enable/disable the connection).
2. Run the NET configuration utility (don't know why this works but it does).
|
|
|
|
|
EdgarBM wrote:
after
uninstalling the beta version of Visual Studio .NET.
Before you installed VS.NET did you make sure to remove all traces of the beta?
Chances are mscoree.dll was still lying around somewhere on your hard drive and that could have screwed some stuff up.
FWIW, when you got the Beta package there were several warnings about not being installed on a primary computer because the recommended way of switching from a beta is to format and reinstall. Fortunately the uninstall actually worked starting with RC0
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
I've got the solution!
Thanks in advance to everybody who tried to help in anyway.
The solution is to recover a bug on the uninstallation program of the Beta version, it's all explained on:
Q312115 - PRB: Visual Studio Debugger Stops Responding After You Install Post-Beta 2 Build
It's about a service called ".NET Framework Support Service" which is not removed during the uninstall and produces all this problem. You must only to disable it and reinitialize the computer (find it at the Control Panel - Administrative Tools - Services, and disable it through Properties window).
Thanks to everyone.
Edgar
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
In the good old days, when I wanted to associate data structures with a combo-box item I'd use SetItemData.
What is the best method to do this in C# as I can't seem to find a SetItemData method. (Why has MS decided to remove a valuable, tried and tested way).
I must be missing something, I've been through the docs on ComboBox.ObjectCollection but it isn't making sense.
Michael
Time flies like an arrow. Fruit flies like a banana
|
|
|
|
|
i had to do the same thing with my ListEx[^] class, but wasnt sure how to do it. TO get around it, i made an ArrayList, and made a function as part of the class Add that added the relevant information to the Items collection, and also added a stuct of data to the ArrayList.
The position of the struct data in the ArrayList, corresponds to the position of the Item in the Items collection.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
That's a little too hack and slash for my tastes. Especially when sorting, removing and inserting are taken into account.
The ListView control uses the Tag property, but I can't find a way of doing the same for combo-boxes.
This is very annoying, seeing much used functionality being deprecated by .NET
Michael
Time flies like an arrow. Fruit flies like a banana
|
|
|
|
|
|
Make the object you want to associate with the list item override the ToString() method. In ToString(), write code that will spit out the string that represents that object in the list box. Then just add your objects to the list (or combo) via the Items.Add() method. Then use the list (or combo)'s .SelectedItem property to get a reference to the object that is selected.
--
Russell Morris
"Have you gone mad Frink? Put down that science pole!"
|
|
|
|
|
Cool solution. I like it.
A little more work than SetItemData used to be, but it is the best idea so far. Thanks.
Michael
Time flies like an arrow. Fruit flies like a banana
|
|
|
|
|
I am trying to use some functions and structs from Shell32.DLL in my C# project. I have VS create a RCW by adding the COM DLL to my project references. However, after doing this I can only see the Classes, Interfaces, and Delegates from the DLL; I can not see the functions or structs. (Or any of the other NON-CLASS related items)
I understand I can use DllImport to extern the functions I want, but I could not figure out how to use DllImport to extern the Structs I want.
I do not care which method I use to gain access to the features I want of this DLL. If anyone can point me in the right direction, or just flat out let me know how to do what I want.
Thanks in advance…
Aalst
|
|
|
|