-------------------------------------------------------------------- SearchWin2000's Developer Tip -------------------------------------------------------------------- TODAY'S DEVELOPER TIP: XML in .Net: Object serialization ==================================================================== SPONSORED BY: VeriSign - The Internet Trust Company ==================================================================== Pinpoint the right security solution for your company - FREE Guide from industry leader VeriSign gives you all the facts. Learn how to: - Add the most powerful online encryption - 128-bit - Quickly authenticate your site Get your FREE Guide now at http://www.verisign.com/cgi-bin/go.cgi?a=n061140330003000. ==================================================================== "XML in .Net: Object serialization" by Dale Michalk This tip is excerpted from a much longer article on InformIT. It discusses the relationship between Microsoft's .Net framework and XML. -------------------------------------------------------------------- XML stands at the center of the .Net universe. Unlike previous development platforms such as Visual Basic or Java, in which XML parsers were bolted on as XML evolved, the .Net framework was designed to utilize and embrace XML technology at the core of the platform from the start. One of the more powerful facilities is the capability to store and retrieve object state from XML in a process called XML object serialization. This article shows how to use this capability to parse and create XML documents with ease and minimal coding. The .Net framework provides high-fidelity type information about classes loaded into the Common Language Runtime. The runtime provides a fully populated System.Type object when invoking the GetType method of an object or the type of operator with a class name. System.Type provides methods to query for information on the interfaces, methods, properties, events, and fields that a class implements and then dynamically invoke them to retrieve values. Using this information, we could easily build our own program to interpret between object data and XML documents. Fortunately, the class XmlSerializer exists in the framework and is ready and willing to do the job for us. The XmlSerializer handles XML in a manner similar to the approach taken by most XML parsers that comply with DOM interfaces. Like a parser, it scans XML sources to build an object model that the client can eventually access. Instead of building up a model of DOM Infoset items, the XmlSerializer builds up the object structure that relates to the type information provided to it. It also goes in the opposite direction to enumerate the runtime characteristics of a class instance to create an XML document with elements and attributes set to the proper values. To illustrate the serialization process, we will use an object model that represents a security domain similar to that provided by NT/Windows 2000. At the top is a domain object holding a collection of Users and Groups. The users hold authentication information such as usernames and passwords, while the groups hold references to users to organize them for easy access control. All objects in the model have ID information to identify them uniquely outside of their textual names, much like the use of SIDs in NT Security. A good application of this object model is an ASP.Net solution that requires a security database outside the normal NT/Windows 2000 domain infrastructure. The Listing shows the code for our classes. Listing: Code Listing for Domain Security Classes public class Domain { public string ID; public string Name; public User[] Users; public Group[] Groups; } public class User { public string ID; public string Name; public string Password; } public class UserRef { public string ID; } public class Group { public string ID; public string Name; public UserRef[] Users; } -------------------------------------------------------------------- To read all of this tip, click on the link below to visit InformIT. You have to register there, but it's free. [http://www.informit.com/myinformit/login/index.asp?session_id={DABEE542-6ED8-4836-BA4A-215A67B98A70}&t={6373D50E-EF0B-4084-B8A7-032653E262E2}&n={C1E6AB17-02D4-441D-B10C-538501318D8D}] ==================================================================== WIN! WIN! WIN! ==================================================================== September's tip of the month contest is here! Get your tip in early for your chance to win this month's prize - an iBOT Firewire desktop video camera w/microphone! Check out August's winning tips and submit your own at http://searchwin2000.techtarget.com/tipsHallOfFame/0,289489,sid1_prz758210_cts758207,00.html. ==================================================================== FEATURED BOOK -------------------------------------------------------------------- ".Net Framework Essentials" Authors: Hoang Lam and Thuan L. Thai Online Price: $29.95 Publisher Name: O'Reilly & Associates Date published: June 2001 ".Net Framework Essentials" is an objective, concise, and technical overview of the new Microsoft .Net Framework for developing Web applications and services. Specifically written for intermediate to advanced VB, C/C++, Java, and Delphi developers, ".Net Framework Essentials" is also useful to system architects and leaders who are assessing tools for future projects. The authors devote special attention to the writing of .Net components plus Web applications and services. This book takes on all of the most important .Net Framework topics -- from the underlying Common Language Runtime (CLR) to its specialized packages for ASP.Net, Web Forms, Windows Forms, XML and data access (ADO.Net). http://www.digitalguru.com/DigitalGuru/product_detail.asp?catalog_name=Books&category_name=&product_id=0596001657&partner_id=73 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NEW FREE NEWSLETTER! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Register to received searchWin2000's monthly Active Directory tip! Active Directory is perhaps the most complicated part of the Windows 2000 architecture, and the foundation for Exchange 2000 among other programs. Our monthly Active Directory tips will help you with the planning, administration and maintenance of AD services within your distributed networking environments. Don't wait to begin receiving these helpful and timesaving expert tips. Register to receive this newsletter at http://searchwin2000.techtarget.com/register/1,,sid1,00.html. ==================================================================== If you would like to sponsor this or any TechTarget newsletter, please contact Mike Kelly at mailto:[EMAIL PROTECTED]. ==================================================================== If you no longer wish to receive this newsletter simply reply to this message with "REMOVE" in the subject line. Or, visit http://searchWin2000.techtarget.com/register and adjust your subscriptions accordingly. If you choose to unsubscribe using our automated processing, you must send the "REMOVE" request from the email account to which this newsletter was delivered. Please allow 24 hours for your "REMOVE" request to be processed.
