CDBSharp
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Library for reading/writing CDB (Constant Database) files
CDBSharp
========

Library for reading/writing CDB (Constant Database) files

```c#
class Program {
  static void Main(string[] args) {
    using (var writer = new StringCDBWriter("verses.cdb")) {
      foreach (var verse in parseVerses(new StreamReader(new GZipStream(new WebClient().OpenRead("https://s3.amazonaws.com/mongol.ephisys.com/Data/kjv.rawtxt.gz"), CompressionMode.Decompress)))) {
        writer.AddEntry(verse.Key, verse.Value);
      }
    }

    using (var cdb = new StringCDBReader("verses.cdb")) {
      Console.WriteLine(cdb.Find("John3:16").Single());
    }
  }

  private static IEnumerable> parseVerses(StreamReader sr) {
    // Iterator to return verses as long as we keep finding more.  Loads about 31,000 verses.
    while (!sr.EndOfStream) {
      var match = Regex.Match(sr.ReadLine(), @"(?\d*[A-Za-z]+\d+:\d+)\s(?.+$)");
      if (match.Success) {
        yield return new KeyValuePair(match.Groups["Reference"].Value, match.Groups["Verse"].Value);
      }
    }
  }
}
```

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。