473,763 Members | 4,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Singleton (XML) serialization

Hi there,

I have tried to run some samples without succes.
So I have made a new sample. Maybe someone can fix the serialization?

The class "MyProgram" must be saved to an xml file and placed back in the
program with the "open" call.

Hope someone can do something for me.
Thanks,
Arjen
// -------------------------------------------------------------------------

using System;
using System.Collecti ons;

namespace MyProgram {

class MyProgram {

public static Hashtable Persons = new Hashtable();

[STAThread]
static void Main(string[] args) {
Open();

DoSomeThing();

Save();
}

static public void DoSomeThing() {

// New object
Person person = new Person("James", 12);

// Add to the hashtable
Persons.Add( person.GetHashC ode(), person);
}
static void Open() {
// Read the serialization

}

static void Save() {
// Save the serialization

}
}

class Person {
string _name;
int _age;

public Person( string name, int age) {
_name = name;
_age = age;
}
}
}


Nov 15 '05 #1
3 3040
If I have serialized "class MyProgram" in a binary format then I have all
the information of private and public fields or not?

Something like this is what I must have.

Thanks,
Arjen
Nov 15 '05 #2
Yes, you have.

BTW. I have sent a link to a serialization project in one of your other topics. Have a go at it.

--
Cezary Nolewajka
mailto:c.****** *************** @no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Arjen" <bo*****@hotmai l.com> wrote in message news:bv******** **@news1.tilbu1 .nb.home.nl...
If I have serialized "class MyProgram" in a binary format then I have all
the information of private and public fields or not?

Something like this is what I must have.

Thanks,
Arjen

Nov 15 '05 #3
Thanks for your link and support!

It finally works! (YESSS)

Thanks,
Arjen


"Cezary Nolewajka" <c.************ *********@no-sp-am-eh-mail.com> schreef in
bericht news:us******** ******@TK2MSFTN GP11.phx.gbl...
Yes, you have.

BTW. I have sent a link to a serialization project in one of your other
topics. Have a go at it.

--
Cezary Nolewajka
mailto:c.****** *************** @no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Arjen" <bo*****@hotmai l.com> wrote in message
news:bv******** **@news1.tilbu1 .nb.home.nl...
If I have serialized "class MyProgram" in a binary format then I have all
the information of private and public fields or not?

Something like this is what I must have.

Thanks,
Arjen

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2839
by: Leszek | last post by:
Hello, I have the following XML file: <events> <event name="event1"> <sessions> <session date="23 Feb 2004" time="10:00 - 15:00" location="Toronto" /> </sessions> </event>
0
2143
by: Mike | last post by:
Hi, I am consuming a web service in my asp.net application. I added the web references in Visual Studio by pointing to a wsdl file. Visual Studio automatically creates the Reference.cs file and the code that is used to serialize the classes used in the server's service. I create an instance of the input variable, set my values, and pass it to a method. The class is serialized/deserialized for me into an XML string that is sent to the...
1
4365
by: andrewcw | last post by:
There is an error in XML document (1, 2). I used XML spy to create the XML and XSD. When I asked to have the XML validated it said it was OK. I used the .net SDK to generate the class. I have done this before but this time I have no idea why I am getting the error. Any ideas ?? THANKS ! <qcsttatus> <manual sourcerootfolder="" manualname="">
4
2004
by: Michael Maes | last post by:
Hi, How would I make a class implementing a Singleton Pattern serializable. My problem is the Singleton Pattern 'requires' the constructor to be Private and serialization requires the constructor to be Public. Thanks, Michael
3
10837
by: namewitheldbyrequest | last post by:
"The XML element 'EnableTheming' from namespace 'http://tempuri.org/' is already present in the current scope" I created a Web Service: I imported System.Data.SqlClient so I could access SQL server tables programmatically. The web service builds and deploys with no problems. When I try to add the corresponding Web Reference to the Web Site project I get the error listed below. I am able to create other Web Services on the same server...
0
2787
by: =?Utf-8?B?Y2luZHk=?= | last post by:
I know I wrote before a week ago when I knew even less than now but I am getting better please anyone give me a clue or an example. Am I completely off track? I have a datarow in a table with the fields to map to an xsd. Then i call a web service upload method that wants the xml strongly typed to the xsd in a string. so I have generated a class from a xsd newcust.cs in .net 1.1 c# to start with just to see what it means to use an...
0
6616
by: bharathreddy | last post by:
Before going to that i want to say few thing on serialization : Serialization is the process of converting an object into a form that can be readily transported. For example, you can serialize an object and transport it over the Internet using HTTP between a client and a server. On the other end, deserialization reconstructs the object from the stream. XML serialization serializes only the public fields and property values of an object...
1
11100
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject : IPersistable;
6
1216
by: Monty | last post by:
Hello, I have a singleton settings class (.Net 2.0 framework) that I serialize/deserialize to XML. On my settings class is a shared list of integers. If I have two numbers in my list and I deserialize my class successive times, the count of integers in my list grows by 2 each time when I would expect it to remain at 2. When I run this code (below) and click the button multiple times, my immediate window shows the following results: 2 4...
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10144
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.