G
Guest
using the June 2005 edition of the Ent Lib.
I can serialize a SqlParameterCollection using
ConfigurationManager.GetConfiguration() but WriteConfiguration() does not
seem to be able to deserialize that same parameter. A small sample app
follows.
How can I accomplish this?
In the example below mytest is created with the _myName variable as "Billy"
but the _pcol variable as undefined.
****code example************
using System;
using System.Data.SqlClient;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Configuration;
namespace AccountUserMigration
{
public class Test{
private SqlParameterCollection _pcol;
private string _myName;
public string myName{
get{return this._myName;}
set{this._myName = value;}
}
public SqlParameterCollection pcol{
get{return this._pcol;}
set{this._pcol = value;}
}
public Test(){}
public void PrepForSerialization(){
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add("@one",SqlDbType.VarChar);
cmd.Parameters.Add("@two",SqlDbType.Int);
this.pcol = cmd.Parameters;
this.myName = "Billy";
}
static void Main(){
//Test mytest = new Test(), mytest2 = new Test();
//mytest.PrepForSerialization();
//ConfigurationManager.WriteConfiguration("TestConfiguration",mytest);
Test mytest2 =
(Test)ConfigurationManager.GetConfiguration("TestConfiguration") as Test;
}
}
}
**************************
I can serialize a SqlParameterCollection using
ConfigurationManager.GetConfiguration() but WriteConfiguration() does not
seem to be able to deserialize that same parameter. A small sample app
follows.
How can I accomplish this?
In the example below mytest is created with the _myName variable as "Billy"
but the _pcol variable as undefined.
****code example************
using System;
using System.Data.SqlClient;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Configuration;
namespace AccountUserMigration
{
public class Test{
private SqlParameterCollection _pcol;
private string _myName;
public string myName{
get{return this._myName;}
set{this._myName = value;}
}
public SqlParameterCollection pcol{
get{return this._pcol;}
set{this._pcol = value;}
}
public Test(){}
public void PrepForSerialization(){
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add("@one",SqlDbType.VarChar);
cmd.Parameters.Add("@two",SqlDbType.Int);
this.pcol = cmd.Parameters;
this.myName = "Billy";
}
static void Main(){
//Test mytest = new Test(), mytest2 = new Test();
//mytest.PrepForSerialization();
//ConfigurationManager.WriteConfiguration("TestConfiguration",mytest);
Test mytest2 =
(Test)ConfigurationManager.GetConfiguration("TestConfiguration") as Test;
}
}
}
**************************