/
Dictionary.cs
42 lines (37 loc) · 1.3 KB
/
Dictionary.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
namespace CC_CEDICT.WindowsPhone
{
public class Dictionary : StreamLineArray<DictionaryRecord>
{
public Dictionary<string, string> Header = new Dictionary<string, string>();
public Dictionary(string path)
{
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
Read(new IsolatedStorageFileStream(path, FileMode.Open, store));
}
protected override bool ProcessHeader(ref byte[] data, int offset, int length)
{
if (data[offset] != (byte)'#')
return false;
if (data[offset + 1] == (byte)'!' && data[offset + 2] == (byte)' ')
{
string header = System.Text.Encoding.UTF8.GetString(data, offset + 3, length - 3);
int i = header.IndexOf("=");
string key = header.Substring(0, i);
string value = header.Substring(i + 1);
switch (key)
{
//case ...
default:
Header[key] = value;
break;
}
}
return true;
}
}
}