Re: how to create instance after passing class type to function
- From: micha <nospam@xxxxxxxxx>
- Date: Tue, 27 Dec 2005 06:49:21 -0800
Jon,
I'll try to be much more specific:
next 2 functions belong to class which knows the definition of the
configuration class. I want to move that class to an independent dll as
I said above.
public Configuration Deserialize()
{
XmlSerializer serializer =
new XmlSerializer(typeof(Configuration));
FileStream stream = new FileStream
(fileName_,FileMode.Open, FileAccess.Read);
Configuration configuration =
(Configuration)serializer.Deserialize(stream);
stream.Close();
return configuration;
}
public void Serialize(Configuration config)
{
Configuration cfgAsReadFromFile =
this.Deserialize(typeof(Config));
if (!config.IsEqual(cfgAsReadFromFile))
...
XmlSerializer writeSerializer =
new XmlSerializer( typeof( Configuration ) );
MemoryStream memoryStream = new MemoryStream();
writeSerializer.Serialize( memoryStream, config );
...
}
*** Sent via Developersdex http://www.developersdex.com ***
.
- Follow-Ups:
- Re: how to create instance after passing class type to function
- From: Jon Skeet [C# MVP]
- Re: how to create instance after passing class type to function
- References:
- Re: how to create instance after passing class type to function
- From: Michael Lev
- Re: how to create instance after passing class type to function
- Prev by Date: Re: OO DB question
- Next by Date: Re: OO DB question
- Previous by thread: Re: how to create instance after passing class type to function
- Next by thread: Re: how to create instance after passing class type to function
- Index(es):
Relevant Pages
|