473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Serializing "Type" class

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.
Nov 12 '05 #1
3 4753
Maersa wrote:
Was anybody able to serialize the "Type" class properly using
XmlSerializer()....


AFAIK that's impossible due to security reasons.
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #2
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
"Oleg Tkachenko" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
Maersa wrote:
Was anybody able to serialize the "Type" class properly using
XmlSerializer()....


AFAIK that's impossible due to security reasons.
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #3
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.

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

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

"Maersa" <ma*****@hotmail.com> wrote in message
news:Oa**************@TK2MSFTNGP12.phx.gbl...
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.

Nov 12 '05 #4

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

Similar topics

6
by: Web Developer | last post by:
Hi, I come across the term "type checking" very often in my readings on C++, and have never heard it in Java. Besides the simplistic answer that it checks the "type", what more does it mean? ...
0
by: Pankaj Jain | last post by:
Hi All, I have a class A which is derived from ServicesComponent to participate in automatic transaction with falg Transaction.Required. Class A is exposed to client through remoting on Http...
5
by: Lou Pecora | last post by:
g++ compiler error question. I have a container C whose constructor takes a class B that is inherited from an abstract class A. So I have the line of code: B binstance; C ...
6
by: geoffrobinson | last post by:
Hi, I'm serializing an object using XmlSerializer. It is serializing, but we are getting errors upon deserialization. We use the following code to serialize: FileStream fs = new...
6
by: Kay | last post by:
Hi all, In vb6, I can define a custom type like this: Private Type uClient sName As String sMonday As Double sMondayHeadCnt As Integer End Type
15
by: Cruella DeVille | last post by:
I'm trying to implement a bookmark-url program, which accepts user input and puts the strings in a dictionary. Somehow I'm not able to iterate myDictionary of type Dict{} When I write print...
3
by: IR | last post by:
Hi, I've been trying to do the following (which doesn't compile) : template<class T, class F = Example<T struct Example { F foo(); };
3
by: phil | last post by:
I have written a little application that can grab part of a page from a web site. I then want to take this result and be able to serialize it so that it can be stored as XML. I am storing these...
0
by: Jeff Louie | last post by:
Robert.. You can use interfaces or an abstract base class to abstract out the functionality of the plug ins. You then program to the abstraction. In the case of an interface, you program to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.