473,654 Members | 3,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I make a class from XML? Serialize?

Hi guys,

I need a way to dynamically change (or create) a custom class using an
external xml file. Can this be done at all? This is what the class looks
like:

Public Class MemberData
Private _EmailGUID As String
Private _Email As String
Private _FirstName As String
Private _LastName As String
Private _Title As String
Private _Company As String
Private _Address As String
Private _PostalCode As Integer
Private _City As String
Private _Phone As String
Private _Active As Integer
Private _RegDate As DateTime
Private _ChangeDate As DateTime

Public Sub New()
MyBase.New()

_EmailGUID = ""
_Email = ""
_FirstName = ""
_LastName = ""
_Title = ""
_Company = ""
_Address = ""
_PostalCode = 0
_City = ""
_Phone = ""
_Active = 0
_RegDate = Nothing
_ChangeDate = Nothing
_SoftBounces = 0
_HardBounces = 0
_GroupIDs = ""

End Sub

Public Property EmailGUID() As String
Get
Return _EmailGUID
End Get
Set(ByVal Value As String)
If ((Value Is Nothing) OrElse (Value.Length = 0)) Then
Throw New Exception("The email address identifier cannot be
empty")
End If
_EmailGUID = Value
End Set
End Property

Public Property Email() As String
Get
Return _Email
End Get
Set(ByVal Value As String)
If ((Value Is Nothing) OrElse (Value.Length = 0)) Then
Throw New Exception("The email address cannot be empty")
End If
_Email = Value
End Set
End Property

[...]

End Class
Thanks.
Regards Jonah
Nov 19 '05 #1
12 4801
Nak
Hi there,

Do you mean during Run-time? If so then I don't believe so. Or do you
mean at Design-time? If so then it is "possible" but you would need to
either find an application that can create a class from an XML file or make
one yourself, out of interest what purpose would it serve?

Nick.

"Jonah Olsson" <jo***@IHateSpa m.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi guys,

I need a way to dynamically change (or create) a custom class using an
external xml file. Can this be done at all? This is what the class looks
like:

Public Class MemberData
Private _EmailGUID As String
Private _Email As String
Private _FirstName As String
Private _LastName As String
Private _Title As String
Private _Company As String
Private _Address As String
Private _PostalCode As Integer
Private _City As String
Private _Phone As String
Private _Active As Integer
Private _RegDate As DateTime
Private _ChangeDate As DateTime

Public Sub New()
MyBase.New()

_EmailGUID = ""
_Email = ""
_FirstName = ""
_LastName = ""
_Title = ""
_Company = ""
_Address = ""
_PostalCode = 0
_City = ""
_Phone = ""
_Active = 0
_RegDate = Nothing
_ChangeDate = Nothing
_SoftBounces = 0
_HardBounces = 0
_GroupIDs = ""

End Sub

Public Property EmailGUID() As String
Get
Return _EmailGUID
End Get
Set(ByVal Value As String)
If ((Value Is Nothing) OrElse (Value.Length = 0)) Then
Throw New Exception("The email address identifier cannot be empty")
End If
_EmailGUID = Value
End Set
End Property

Public Property Email() As String
Get
Return _Email
End Get
Set(ByVal Value As String)
If ((Value Is Nothing) OrElse (Value.Length = 0)) Then
Throw New Exception("The email address cannot be empty")
End If
_Email = Value
End Set
End Property

[...]

End Class
Thanks.
Regards Jonah

Nov 19 '05 #2
Hi Nick,

Here's the deal; I'm trying to create a Web Service to be run as an engine
for several client web applications. The engine takes care of all
communication with each database.
The reason I say 'each' is that a customer may use their own SQL server. All
this is just testing, but I came up with the idea when looking at an example
how to dynamically create stored procedures using XML files
(http://www.fawcette.com/xmlmag/2002_...lin_11_05_02/). Since
I use the MemberData class in the function that contains the call to the
Stored Procedure, and I can change the parameters in the SP using an XML
file, why shouldn't I be able to also make the MemberData class dynamic.

Say, one customer needs to add "Department " to the MemberData class. This
can easily be done in the XML file for the SP, but how to add it to the
MemberData class? I just don't want to re-build the entire Web Service
application.

I'm not sure though if I explained this so people can understand me... =)

Jonah

"Nak" <a@a.com> skrev i meddelandet
news:uc******** ******@TK2MSFTN GP09.phx.gbl...
Hi there,

Do you mean during Run-time? If so then I don't believe so. Or do you
mean at Design-time? If so then it is "possible" but you would need to
either find an application that can create a class from an XML file or make one yourself, out of interest what purpose would it serve?

Nick.

Nov 19 '05 #3
yoz
I am not sure if you want to do it at runtime, but if you do, create a C#
class from the XML (hey you can even do it with XSLT ;-) and use the free
csc.exe (C# compiler) in your windows/Microsoft.NET folder to compile.

If you really want to make things hard for yourself, I know (heard) there
are helper classes to create Assemblies straight without code. I don't have
the book with me, but they seem to exists. naaaaaa, option 1 would be far
cheaper.

Yoz

"Jonah Olsson" <jo***@IHateSpa m.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi guys,

I need a way to dynamically change (or create) a custom class using an
external xml file. Can this be done at all? This is what the class looks
like:

Public Class MemberData
Private _EmailGUID As String
Private _Email As String
Private _FirstName As String
Private _LastName As String
Private _Title As String
Private _Company As String
Private _Address As String
Private _PostalCode As Integer
Private _City As String
Private _Phone As String
Private _Active As Integer
Private _RegDate As DateTime
Private _ChangeDate As DateTime

Public Sub New()
MyBase.New()

_EmailGUID = ""
_Email = ""
_FirstName = ""
_LastName = ""
_Title = ""
_Company = ""
_Address = ""
_PostalCode = 0
_City = ""
_Phone = ""
_Active = 0
_RegDate = Nothing
_ChangeDate = Nothing
_SoftBounces = 0
_HardBounces = 0
_GroupIDs = ""

End Sub

Public Property EmailGUID() As String
Get
Return _EmailGUID
End Get
Set(ByVal Value As String)
If ((Value Is Nothing) OrElse (Value.Length = 0)) Then
Throw New Exception("The email address identifier cannot be empty")
End If
_EmailGUID = Value
End Set
End Property

Public Property Email() As String
Get
Return _Email
End Get
Set(ByVal Value As String)
If ((Value Is Nothing) OrElse (Value.Length = 0)) Then
Throw New Exception("The email address cannot be empty")
End If
_Email = Value
End Set
End Property

[...]

End Class
Thanks.
Regards Jonah

Nov 19 '05 #4
Nak
Hi Jonah,

Sorry I have no idea about Web Services at the moment, I haven't gotten
into any of that. But by the sounds of things I am sure that you can make
the engine that you want, I just do not have the knowledge in that field to
provide enough assistance, sorry :-( Maybe someone else will offer advice
here.

Nick.

"Jonah Olsson" <jo***@IHateSpa m.com> wrote in message
news:uW******** ******@TK2MSFTN GP09.phx.gbl...
Hi Nick,

Here's the deal; I'm trying to create a Web Service to be run as an engine
for several client web applications. The engine takes care of all
communication with each database.
The reason I say 'each' is that a customer may use their own SQL server. All this is just testing, but I came up with the idea when looking at an example how to dynamically create stored procedures using XML files
(http://www.fawcette.com/xmlmag/2002_...lin_11_05_02/). Since I use the MemberData class in the function that contains the call to the
Stored Procedure, and I can change the parameters in the SP using an XML
file, why shouldn't I be able to also make the MemberData class dynamic.

Say, one customer needs to add "Department " to the MemberData class. This
can easily be done in the XML file for the SP, but how to add it to the
MemberData class? I just don't want to re-build the entire Web Service
application.

I'm not sure though if I explained this so people can understand me... =)

Jonah

"Nak" <a@a.com> skrev i meddelandet
news:uc******** ******@TK2MSFTN GP09.phx.gbl...
Hi there,

Do you mean during Run-time? If so then I don't believe so. Or do you mean at Design-time? If so then it is "possible" but you would need to
either find an application that can create a class from an XML file or

make
one yourself, out of interest what purpose would it serve?

Nick.


Nov 19 '05 #5
yoz
What you seem to want is to create dynamic web services where you would
specify an xml and it will create a web service that will be mediating
between the database and the client. I am making this assumption for the
rest of the mail.

1) you create an object that mirror the table (or your xml will have to map
database field to .NET Class field) in a C# code and compile it with csc.

2) then you create an object with methods such as Select which returns an
array of the type you created in step 1. You compile this also in another
assembly (maybe you can combine both into one assembly?)

Either:

3a) Make it available via a Remote Object

http://msdn.microsoft.com/architectu...SecNetHT15.asp

The executable could be a remote service.

or

3b) you can create an asmx to put on IIS that provides the Soap Service.

Hopes that help, I am just think aloud here...
There is a tool called Program Files\Microsoft .NET\SDK\v1.1\B in\SoapSuds.exe
(look on google for "soapsuds") . Have a look at it, it may help.

http://msdn.microsoft.com/library/de...oapsudsexe.asp

PS: You can also have a thread that look for change in XML to regenerate
what has changed. You can even work of a database schema. good luck.
"Jonah Olsson" <jo***@IHateSpa m.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi Yoz,

..and maybe I'm in deep water :)
Should I reconsider the entire design? Maybe each client web application has to be custom built to match their database? What do you suggest?

Thanks
Jonah
"yoz" <netfever@hot_R EMOVE_SPAM_mail .com> skrev i meddelandet
news:XH******** *********@news-binary.blueyond er.co.uk...
I am not sure if you want to do it at runtime, but if you do, create a C# class from the XML (hey you can even do it with XSLT ;-) and use the free csc.exe (C# compiler) in your windows/Microsoft.NET folder to compile.

If you really want to make things hard for yourself, I know (heard) there are helper classes to create Assemblies straight without code. I don't

have
the book with me, but they seem to exists. naaaaaa, option 1 would be far cheaper.


Nov 19 '05 #6
Thanks anyway Nick! :-)

Jonah

"Nak" <a@a.com> skrev i meddelandet
news:Ob******** ******@TK2MSFTN GP09.phx.gbl...
Hi Jonah,

Sorry I have no idea about Web Services at the moment, I haven't gotten into any of that. But by the sounds of things I am sure that you can make
the engine that you want, I just do not have the knowledge in that field to provide enough assistance, sorry :-( Maybe someone else will offer advice
here.

Nick.

Nov 19 '05 #7
Thanks Yoz!
Your information seems very interesting and I'll start digging into it first
thing tomorrow morning.

Jonah
Nov 19 '05 #8
Cor
Jonah,
It seems clear, but it is not for me, you say a Web Service to run as an
engine (Webservice?) for several client web applications. There is a lot of
difference in that. When it is a webService who runs on side A and then
takes action on Side B will be very complex with authoring, but maybe I see
things wrong.

Like Nick I do not know if I can help you, I do know very few from SQL but
maybe this group can help you together.

And of course, when this solution can made with C# it can be made better
with VB.Net.

Cor



"Jonah Olsson" <jo***@IHateSpa m.com> schreef in bericht
news:uW******** ******@TK2MSFTN GP09.phx.gbl...
Hi Nick,

Here's the deal; I'm trying to create a Web Service to be run as an engine
for several client web applications. The engine takes care of all
communication with each database.
The reason I say 'each' is that a customer may use their own SQL server. All this is just testing, but I came up with the idea when looking at an example how to dynamically create stored procedures using XML files
(http://www.fawcette.com/xmlmag/2002_...lin_11_05_02/). Since I use the MemberData class in the function that contains the call to the
Stored Procedure, and I can change the parameters in the SP using an XML
file, why shouldn't I be able to also make the MemberData class dynamic.

Say, one customer needs to add "Department " to the MemberData class. This
can easily be done in the XML file for the SP, but how to add it to the
MemberData class? I just don't want to re-build the entire Web Service
application.

I'm not sure though if I explained this so people can understand me... =)

Jonah

"Nak" <a@a.com> skrev i meddelandet
news:uc******** ******@TK2MSFTN GP09.phx.gbl...
Hi there,

Do you mean during Run-time? If so then I don't believe so. Or do you mean at Design-time? If so then it is "possible" but you would need to
either find an application that can create a class from an XML file or

make
one yourself, out of interest what purpose would it serve?

Nick.


Nov 19 '05 #9
yoz

"Cor" <no*@non.com> wrote in message
news:3f******** *************** @reader21.wxs.n l...
And of course, when this solution can made with C# it can be made better
with VB.Net.


better with vb.net??
Nov 19 '05 #10

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

Similar topics

0
1478
by: Rob Long | last post by:
Hey I'm building a webapp with tons of objects all over the place, a lot of which are quite complex, meaning they could have many subclasses and many nested object members. I'm implementing a memory caching mechanism to store these objects between requests and share them between different user sessions. In order for my memory caching mechanism to work, objects must be serialised before they are placed into the cache. In PHP5, this
3
18806
by: Amy L. | last post by:
I have a class that contains a string array. However, I can't get this object to serialize in the xml output. Is there a trick to get a string to serialize? Thanks Amy.
10
4148
by: Dan | last post by:
All I Am Attempting To Serialize An Object To An XML File. Here Is The Code For That public string SaveNewSurvey( MutualSurveyObject mso_TempObject, int i_JobID ) { string s_RootFileName; string s_FinalFileName; try
3
1452
by: Alex Nitulescu | last post by:
_______________________________________________________________________________________ System.IO.FileNotFoundException: File or assembly name biypfduw.dll, or one of its dependencies, was not found. File name: "biypfduw.dll" at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark) at...
1
5637
by: Samuel R. Neff | last post by:
We're using XmlSerializer to serialize our data objects for persistence in a WinForms app. This is our primary data store, we're not web connected and are not using a database. We've had to program some of our classes in undesired ways to support XmlSerializer and it's limitations (public new constructor, only public properties, no dictionary support, etc). We just came across a note in one of the articles on XML Serialization that...
11
1560
by: Charles Law | last post by:
I have just been asked how to share functions and properties between two running applications. For example, I have App1 and App2 both running on the same machine. App1 uses a DLL (perhaps) that contains function SetProp(). When App1 calls it, a property in the DLL is set to "abc". App2 calls a function GetProp(), in the same DLL. GetProp() should return "abc". This sounds like a simple thing to do, but making the DLL variable shared and...
1
831
by: Peter Nofelt | last post by:
Hey All, I am having issue with serializing a class and its base class using ..net 2.0. I am using IXmlSerializable I've provided code displaying my at the bottom of this post. Thanks ahead of time for any help or feedback. Cheers, Peter
2
5014
by: Jinsong Liu | last post by:
I have following 3 classes public class MyMainClass { MyCollection<MyObject> m_oMyObjectCollection = null; private string m_sID = string.Empty; public MyCollection<MyObject> Collection {
0
1183
by: RogerD | last post by:
Hello All, I have a custom class (Collar) that is a property of another custom class (Dog) which inherits from (Animal). I want to serialize Dog and have the properties from Collar appear as attributes on the Dog xml element. What I have now:
0
1146
by: shapper | last post by:
Hello, I followed some examples in internet and in MSDN web site to create a serializable class. Basically, I need to serialize a class to binary so I can save it in an SQL 2005 table using a column of type VARBINARY (SQL 2005). And also deserialize and return the class. My problem is how to use the class. Of course I know how to create an
0
8379
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8294
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
8816
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
8709
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...
1
8494
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
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
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2719
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

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.