PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/NCldrBuilder/NCldrBuilderOptions.cs

https://github.com/GuySmithFerrier/NCLDR
C# | 132 lines | 100 code | 32 blank | 0 comment | 0 complexity | 352c4be100ac922bd23de08680471e53 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Xml;
  8. using System.Xml.Linq;
  9. using System.Xml.Serialization;
  10. namespace NCldr.Builder
  11. {
  12. public class NCldrBuilderOptions
  13. {
  14. public NCldrBuilderOptions()
  15. {
  16. this.CultureOptions = new NCldrBuilderCultureOptions();
  17. this.IncludeCultureNames = true;
  18. this.IncludeCharacterFallbacks = true;
  19. this.IncludeCultures = true;
  20. this.IncludeCurrencies = true;
  21. this.IncludeCurrencyFractions = true;
  22. this.IncludeCalendarTypes = true;
  23. this.IncludeCalendarPreferences = true;
  24. this.IncludeDayPeriodRuleSets = true;
  25. this.IncludeGenderLists = true;
  26. this.IncludeLanguageMatches = true;
  27. this.IncludeLikelySubTags = true;
  28. this.IncludeMeasurementData = true;
  29. this.IncludeMetaTimeZones = true;
  30. this.IncludeNumberingSystems = true;
  31. this.IncludeOrdinalRuleSets = true;
  32. this.IncludeParentCultures = true;
  33. this.IncludePluralRuleSets = true;
  34. this.IncludePostcodeRegexes = true;
  35. this.IncludeReferences = true;
  36. this.IncludeRegionCodes = true;
  37. this.IncludeRegionGroups = true;
  38. this.IncludeRegionInformations = true;
  39. this.IncludeRegionTelephoneCodes = true;
  40. this.IncludeTimeData = true;
  41. this.IncludeTimeZones = true;
  42. this.IncludeWeekData = true;
  43. this.IncludeWindowsMetaTimeZones = true;
  44. }
  45. public NCldrBuilderCultureOptions CultureOptions { get; set; }
  46. public bool IncludeCharacterFallbacks { get; set; }
  47. public bool IncludeCultureNames { get; set; }
  48. public bool IncludeCultures { get; set; }
  49. public bool IncludeCurrencies { get; set; }
  50. public bool IncludeCurrencyFractions { get; set; }
  51. public bool IncludeCalendarTypes { get; set; }
  52. public bool IncludeCalendarPreferences { get; set; }
  53. public bool IncludeDayPeriodRuleSets { get; set; }
  54. public bool IncludeGenderLists { get; set; }
  55. public bool IncludeLanguageMatches { get; set; }
  56. public bool IncludeLikelySubTags { get; set; }
  57. public bool IncludeMeasurementData { get; set; }
  58. public bool IncludeMetaTimeZones { get; set; }
  59. public bool IncludeNumberingSystems { get; set; }
  60. public bool IncludeOrdinalRuleSets { get; set; }
  61. public bool IncludeParentCultures { get; set; }
  62. public bool IncludePluralRuleSets { get; set; }
  63. public bool IncludePostcodeRegexes { get; set; }
  64. public bool IncludeReferences { get; set; }
  65. public bool IncludeRegionCodes { get; set; }
  66. public bool IncludeRegionGroups { get; set; }
  67. public bool IncludeRegionInformations { get; set; }
  68. public bool IncludeRegionTelephoneCodes { get; set; }
  69. public bool IncludeTimeData { get; set; }
  70. public bool IncludeTimeZones { get; set; }
  71. public bool IncludeWeekData { get; set; }
  72. public bool IncludeWindowsMetaTimeZones { get; set; }
  73. public void Save(string filename)
  74. {
  75. XmlSerializer serializer = new XmlSerializer(this.GetType());
  76. FileStream fileStream = new FileStream(filename, FileMode.Create);
  77. try
  78. {
  79. serializer.Serialize(fileStream, this);
  80. }
  81. finally
  82. {
  83. fileStream.Close();
  84. }
  85. }
  86. public static NCldrBuilderOptions Load(string filename)
  87. {
  88. XmlSerializer serializer = new XmlSerializer(typeof(NCldrBuilderOptions));
  89. FileStream fileStream = new FileStream(filename, FileMode.Open);
  90. try
  91. {
  92. return (NCldrBuilderOptions)serializer.Deserialize(fileStream);
  93. }
  94. finally
  95. {
  96. fileStream.Close();
  97. }
  98. }
  99. }
  100. }