|
Christian, I don't claim to know it all so please teach me, I'm curious:
A delegate is a more or less a memory pointer to some routine. Given that, how would a delegate help? How does the delegate "expose" the arraylist variable? You would need to call a routine for adding or removing or searching, or returning the arraylist itself, etc. With all of that needed functionality could one single pointer give the developer that? You can't overload a delegate can you? Also, I would need to pass the pointer to every object that needed it which may or may not possible depending on how the object was created.
Thanks,
Nathan
|
|
|
|
|
nlarson11 wrote: Given that, how would a delegate help?
Because a global variable is essentialy the easy solution to the question 'how do I make this visible in more than one place', when often the real question is 'when my classes data is updated, I need to let some clients know about it'. As such, you can define an event, such as 'ImageListUpdated', which passes the list directly to the clients that subscribe to it. This means that the access to the information is one way, and rigidly defined in terms of when it occurs.
nlarson11 wrote: You can't overload a delegate can you?
More than one client can subscribe to an event, so even if three classes need the message, it is not a big deal
nlarson11 wrote: Also, I would need to pass the pointer to every object that needed it which may or may not possible depending on how the object was created.
When would that not be possible ? How is it different to having it exposed on a global, in that regard ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Another excellent reponce Christian
I don't need to define an event as the event is allready happening when the user selected the directory to view the images from. The images are on the users computer, all i'm doing is getting their path\file names. The problem comes when the user wants to flip though the images as this is a seperate event.
At the moment this is not a problem,as I'm using Public Shared var. (See I did not use the word Global)
a question.... how much time & memory would it take to load into a imagelist 300+ images, of course some of the images could be different sizes, which then rules out using Imagelist. Myself I have a directory which contains images of different sizes, and i'm sure other users would be the same. So I don't think that I'll be using Imagelist any time soon.;P
|
|
|
|
|
WestSideRailways wrote: how much time & memory would it take to load into a imagelist 300+ images
I"m not sure, but the images themselves are passed by ref, so I wouldn't expect it to be much
I'd just put them in a List if I had to pass them around.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi
I'm using vb.net 2005 , when I go to run the project from the design mode it's OK , but when I go to run the EXE of the project , I found that the splash screen is appearing and then the StartUp form is running behinde other windows openning programs ,
this problem isn't appear when I run the program from it's source on vb.net envirnment , but on Exe , it's appear .....
jooooo
|
|
|
|
|
I have a class that I want to save to viewstate. In order to save it to viewstate it has to be serializable. How do you serialize a class and then unserialize it.
thanks
John
|
|
|
|
|
You mark it as serialisable, if it contains only POD, that is all you need, I believe.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
This book shows you how to serialize a class and deserialize it.
good book
|
|
|
|
|
John,
<Serializable() _
public class MyEntity
public sName as string
<Xml.Serialization.XmlIgnore()>public oObj as object
.
.
end class
Note: private variables will not be serialized
Note: some variable types cannot be serialized
Note: if you dont' want the value to be seralized you need to ingore the value
Note: import these libraries
Imports System.io
Imports System.Xml
Imports System.Xml.Serialization
-------
To Serialize:
Public Function sSerializeEntity(ByVal oEntity As Object) As String
Dim oSerializer As New XmlSerializer(oEntity.GetType)
Dim oSR As New MemoryStream, bt() As Byte
Try
oSerializer.Serialize(oSR, oEntity)
bt = oSR.GetBuffer
sSerializeEntity = System.Text.Encoding.ASCII.GetString(bt)
oSR.Close()
oSR = Nothing
oSerializer = Nothing
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Function
-----------
To Deserialize:
Public Sub DeSerializeEntity(ByVal sEntity As String, ByRef oEntity As Object)
Dim oSerializer As New XmlSerializer(oEntity.GetType)
Dim oSR As MemoryStream
Try
oSR = New MemoryStream(System.Text.Encoding.ASCII.GetBytes(sEntity))
oEntity = oSerializer.Deserialize(oSR)
oSR.Close()
oSR = Nothing
oSerializer = Nothing
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
---------------
** to serlialize object **
Dim oMyEntity as new MyEntity
oMyEntity.sName = "Test"
dim sEntity As string = sSerializeEntity(oMyEntity)
'''''''serialized''''''' you can pass the value of sEntity anywhere
** to put back into an object **
Dim oMyEntity as new MyEntity
DeSerializeEntity(sEntity,oMyEntity)
'''''''deserialized''''''' now you can use the object
msgbox(oMyEntity.sName)
|
|
|
|
|
|
i use vb.net2005.
My database is Access.
I use Crystal report for reporting.
when i move my project database to another place(drive),Crystalreportviewr can not find database ,then, the program show "Database Login" Windows.
how can i create a mobile database by crystal report and Access.
thanks
|
|
|
|
|
Does anyone know any good or decent testing tools for vs 2003 since they don't provide you with any.
My goal is to test methods (i already know about Nunit). in VS 2005, we can use the object test bench to create instances and test methods within the instance. im sort of looking for a tool that does the same. Nunit does no justice.
|
|
|
|
|
How to customize the pacakge and Deployment options of vb.net project so that I can provide an options to users for the installation of application. Same like Ms-Office, Ms-Visual studio.net and so on...
|
|
|
|
|
As far as I know, you can't. The default installer that Windows uses when you package your project is preset. I would suggest a standalone installer, NSIS would be best for what you are trying to do.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
If a client is expecting XML to be returned would I do that as a string or just pass a class back with the properties of the items that I need to return? Does the client receive an "XML" value when I do that or a collection of values that must be received into a similar class object and therefore is not read in as straight XML?
Thanks,
Cleako
|
|
|
|
|
From my experience you would just send an XML file which would essentially be a string in a file. Putting the items in a class might be harder to handle. Do you know how the client is parsing the XML? I would assume they would load the XML into an XML document object which just requires a stream reader. They would receive the file as a string and the XML object would handle it from there.
-------------------------------------
Do not do what has already been done.
Absolute power corrupts absolutely.. but it ROCKS absolutely, too.
|
|
|
|
|
When you say send an XML file do you mean create an XMLDocument and then send that back? Im pretty new to dealing with XML and am currently searching the web while I wait on replies.
Cleako
|
|
|
|
|
Depends on how they want it. If you're sending them a physical file or if it's a web service. Physical file would be printing the XML out to a file but you could probably send an XMLDocument to them over a web service. Several ways this could be handled. Have you searched the articles here on CP for suggestions?
-------------------------------------
Do not do what has already been done.
Absolute power corrupts absolutely.. but it ROCKS absolutely, too.
|
|
|
|
|
No, Ive been Googling it. This will not be a public web service in the sense that it will not be available to everyone but only to the sites that my company has created. The client, "site", will send what I understand to be an XML string. I am to return an XML string back. So my original question is, would I just return a string value that is filled with a formatted XML string that I create and also accept one string argument?
What I am seeing in this code that I have inherited from a previous developer is one method returns a string of XML like I understand the process to do, the rest return a response object such as "Person" or "Place" etc. that shows up in XML format on the screen but must be received by a similar object on the other end (or am I wrong about that?).
Cleako
|
|
|
|
|
Yes, you would return a string with the XML tags in it and they will parse that out much like your input procedure does on the string they send you. I would look there if possible to get an idea of what they're doing. If you're sending objects back then there must be something on their end to receive it. It's probably just an object that parses XML into properties and then uses XSLT or something like that to translate on their end. If all they're getting back is a string then that would be your answer. If you're sending the objects then just follow what's been written and bend it to your needs. Possibly see if you can get a client representative to clear up exactly what they are expecting.
-------------------------------------
Do not do what has already been done.
Absolute power corrupts absolutely.. but it ROCKS absolutely, too.
|
|
|
|
|
I will be doing that today I just wanted to make sure that my understanding of the returned format was correct.
According to the receiving end an XML string <> Serialized Object correct?
Cleako
|
|
|
|
|
If you're sending an XML string then yes. I believe you could take an object and parse it to XML with something like a toXML type command. Haven't worked with it for awhile but I think serializable object should be able to break down to a string for sending. Make sense?
-------------------------------------
Do not do what has already been done.
Absolute power corrupts absolutely.. but it ROCKS absolutely, too.
|
|
|
|
|
I didnt think of that, that might be the solution I use to better handle the XML without a lot of clunky code.
So other than pre-serialization if I were to return objResponse to the calling client can that be interpretted the same as a string or does it require a similar object on the other side to accept it? That is what I am really getting at here.
Thanks!
Cleako
|
|
|
|
|
Any of it will probably require SOME work on the other end to process it. You could also ask about this in the XML forum and see what you get there. That might help you more.
-------------------------------------
Do not do what has already been done.
Absolute power corrupts absolutely.. but it ROCKS absolutely, too.
|
|
|
|
|
Why not use SOAP for requests and responces? If you are using .NET on both ends SOAP will serailize/deserialize the object for you automatically.
Mike Lasseter
|
|
|
|