DbConfig.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //*******************************
  2. // Created By Rocher Kong
  3. // Github https://github.com/RocherKong
  4. // Date 2018.02.09
  5. //*******************************
  6. using System;
  7. namespace IP2Region.Models
  8. {
  9. public class DbMakerConfigException : Exception
  10. {
  11. public string ErrMsg { get; private set; }
  12. public DbMakerConfigException(string errMsg)
  13. {
  14. ErrMsg = errMsg;
  15. }
  16. }
  17. public class DbConfig
  18. {
  19. public int TotalHeaderSize
  20. {
  21. get;
  22. private set;
  23. }
  24. public int indexBlockSize
  25. {
  26. get;
  27. private set;
  28. }
  29. public DbConfig(int totalHeaderSize)
  30. {
  31. if ((totalHeaderSize % 8) != 0)
  32. {
  33. throw new DbMakerConfigException("totalHeaderSize must be times of 8");
  34. }
  35. TotalHeaderSize = totalHeaderSize;
  36. //4 * 2048
  37. indexBlockSize = 8192;
  38. }
  39. public DbConfig():this(8 * 2048)
  40. {
  41. }
  42. }
  43. }