actually ...

XmlSerializer.FromTypes()

will give you a serializer instance that lets you process multiple types,
the constructor I gave you will only process ToolDescriptor objects (any
anything referenced by them ).

If ToolDescriptor has any members that need additional types declared to the
serializer, you can use another constructor for the:

public XmlSerializer(
   Type type,
   Type[] extraTypes
);

where the extraTypes array declares additional types the XmlSerializer needs
to process.

HTH again,
Christoph


----- Original Message -----
From: "Sam Gentile" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 25, 2002 11:14 AM
Subject: Re: [DOTNET] Some Basic XML "Serialization" Questions


> On Wed, 24 Apr 2002 10:05:01 -0700, Justin Rudd
> <[EMAIL PROTECTED]> wrote:
>
> >[code snipped]
> >
> >Why would you do all that work when you can just do this...
> >
> >public class Std {
> >   public Int32 MyVal;
> >   public String MyString;
> >}
> >
> >public class MyObject {
> >   public Std Std;
> >}
> >Type[]types = new Type[]{typeof(MyObject)};
> >XmlSerializer[] s = XmlSerializer.FromTypes(types);
> >
> >Plus this is supported by Microsoft.  IXmlSerializable is not supported
> by MS (or so says my help files).
> >
> >If you have more complicated XML, then you can use the serialization
> attributes.  No reason to do it all yourself.
> >
> >Justin
> >
> >You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
> >subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
> Justin, thanks for your response but I am still confused. Why do I need to
> embed the object in another to pass to typeof? And what about setting
> values? I want those to get serialized too. What if I have:
> class Test
>  {
>   /// <summary>
>   /// The main entry point for the application.
>   /// </summary>
>   [STAThread]
>   static void Main()
>   {
>    ToolDescriptor td = new ToolDescriptor();
>    td.Author = "Sam Gentile";
>    td.Description = "Tool Descriptor";
>    td.Name = "Tool Descriptor";
>    td.OrganizationURL = "http://www.microsoft.com";;
>
>    Type[] ourTypes = new Type[] {typeof(td) };
>   }
> How do I get this to work?
>
> You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to