I wanted to store the content of a List into file, for later reload.
But the List contains objects which are non-serializable.
How to achieve this?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
David SmithPosted Oct 7, 2010, 12:07 AM
private List
public static class Extensions
{
public static void WriteAllToConsole(this IEnumerable junk)
{
int counter = 0;
foreach (var item in junk)
{
Console.Write(counter++ + ". ");
Console.WriteLine(item);
}
}
}
public class TestObjectEvent
{
public Int32 TPC_ID;
public Int32 TestSequenceNumber;
public Int32 TestObjectEventNumber;
public string TestObjectName;
public DateTime Start_Time;
public DateTime Stop_Time;
public string TOE_Status;
public override string ToString()
{
return string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}",
TPC_ID,
TestSequenceNumber,
TestObjectEventNumber,
TestObjectName,
Start_Time,
Stop_Time,
TOE_Status);
}
}
then I call the WriteAllToConsoleFunction I created at the top,
TestObjectEventTableList.WriteAllToConsole();
I cut out the code where im filling the TestObjectEventTableList. but this just a ideal, like I said also lookup the objectdumper
David SmithPosted Oct 6, 2010, 11:56 PM
im using a Dictionary
List
also lookup something call objectdumper I havent using it in along time, where you actually dump your object in the ocean if you want or whatever you want to dump it to.
Let me see if I still have a code sample I did a long time ago and I will post a sample
Sam HobbsPosted Oct 6, 2010, 11:18 AM
Read your initial post for this thread; I did. You said "a list". You did not say the data is complicated.
Your problem description is very incomplete.
Jean PaulPosted Oct 6, 2010, 9:20 AM
My list contains objects of Employee, Item, Category etc.. which are having different properties. So for storing into a text file as a record I need to do lot of code and rework whenever the properties get changed.
Also the Employee can have properties of type Project which is another class and Project can be connected to Manager that is another Employee.
Sam HobbsPosted Oct 6, 2010, 5:27 AM