Question

I am writting Windows Phone messanger application and I have dilemma how to store my messages. At this moment my message class looks like:

public class MessageModel
{
    public string Side { get; set; }
    public string Message { get; set; }
    public DateTime TimeStamp { get; set; }
}

I don't know is it good idea to have an class like I mentioned and store them in IsolatedStorage. Is better solution to have a file and save them in XML or JSON format ? Or maybe some database ? In other way having a class of MessageModel makes Binding really easier. I would like to keep my messages in format of dictionary: Dictionary<username, ObservableCollection<MessageModel>> where username key is an string. If you can tell me some advice about that I will really appreciate that.

Was it helpful?

Solution

This is interestinq question. I did some tests. Test algorithm for 1 iteration:

  1. Open data source. (Db connection for Linq to sql. Prepare isostore and streams for reading/writing xml and json)
  2. Prepare new MessageModel. All message text have 150 char.
  3. Apend new message and save it.
  4. Release data sources.

Table below show results for 1000 and 10 000 iterations. Tested on emulator.

Result table

In yours scenario - I don't think you'll have many records. If u don't need any complex query and update etc. XML is good choice. It is easy to use, the resulting file is readable and don't need any third party library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top