How would I go about making this entire class Serializable?
What code would I add to a second constructor that would restore state/values from the XML file (de-serialize)?
using System;
using System.Collections.Generic;
using System.Text;
namespace tgreer
{
public class indexer
{
private Dictionary<string, Int32> _documents;
private Dictionary<string, Int32> _pages;
public indexer()
{
// class constructor
_documents = new Dictionary<string, Int32>(250);
_pages = new Dictionary<string, Int32>(1000);
}
public void addDocIndex(string _seq, Int32 _offset)
{
_documents.Add(_seq, _offset);
}
public void addPageIndex(string _seq, Int32 _offset)
{
_pages.Add(_seq, _offset);
}
}
}
There are just two private dictionaries. The application which uses this class library will add values to the dictionaries by calling the public methods. I need a way to persist any values of a particular instance of this class/object, and to potentially restore them if the proper constructor is called.