Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / November 2003

Tip: Looking for answers? Try searching our database.

Serializing "Type" class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Maersa - 21 Nov 2003 07:42 GMT
Hi All,

Was anybody able to serialize the "Type" class properly using
XmlSerializer()....
Want to serialize and deserialze the Type in a string form, but can this be
done ?

myobj.Type = typeof(System.String) as <type>System.String</type>

thanks a ton.
Oleg Tkachenko - 23 Nov 2003 10:23 GMT
> Was anybody able to serialize the "Type" class properly using
> XmlSerializer()....

AFAIK that's impossible due to security reasons.
Signature

Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Dino Chiesa [Microsoft] - 24 Nov 2003 18:54 GMT
If all you want is the type name, can you use a buddy member that depends on
the actual type?

 public class MyType {
   [XmlIgnore]   // this is not serialized
   public System.Type ActualTypeInstance;

   public System.String TypeName {
     get {
       return ActualTypeInstance.FullName;
     }
     set {
       ActualTypeInstance= System.Type.GetType(value);
     }
   }
 }

-Dino

> > Was anybody able to serialize the "Type" class properly using
> > XmlSerializer()....
>
> AFAIK that's impossible due to security reasons.
Christoph Schittko [MVP] - 28 Nov 2003 21:53 GMT
The XmlSerializer is not really intended for anything but binding XML to
simple data classes, check [0] for a more detailed discussion.

Why do you want to serialize a Type object to a string anyway? There isn't
much state information in a Type object that's interesting to serialize. If
you need to store information about what Type you were dealing with, then
storing the Type's FullName property will suffice.

Signature

HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

[0] http://www.topxml.com/xmlserializer/serializable_classes.asp

> Hi All,
>
[quoted text clipped - 6 lines]
>
> thanks a ton.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.