Re: how to create instance after passing class type to function

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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 ***
.



Relevant Pages

  • Xml :: Deserialize stream of specified range.
    ... I have a potentially very large xml configuration file. ... I could read the range of bytes into a MemoryStream, ...
    (microsoft.public.dotnet.framework)
  • Config Mgmt App Block, XmlSerializer, Array List
    ... XmlSerializerSectionHandler in the Configuration Managment Application ... I can get around this by adding the type specification when I create the ... do this because the XmlSerializer is created by the Configuration Management ...
    (microsoft.public.dotnet.distributed_apps)
  • XmlSerializer constructor
    ... Configuration Exceptionin Dev Studio 2003. ... XmlSerializer serializer= new XmlSerializer); ...
    (microsoft.public.dotnet.xml)
  • how to serialize complex object to configuration file. (.Net Framework 2.0)
    ... will be one property in my custom configuration section. ... configuration will serialize it using XmlSerializer and adds to my ... custom section at the configuration file. ...
    (microsoft.public.dotnet.framework)