/// <summary> /// Load the default LoadCoefficientDatabase for each respective country. /// </summary> /// <remarks>Create</remarks> /// <param name="countryCode">National annex of calculation code (D/DK/EST/FIN/GB/H/N/PL/RO/S/TR)</param> /// <returns></returns> public static LoadCategoryDatabase GetDefault(string countryCode = "S") { string code = RestrictedString.EurocodeType(countryCode); LoadCategoryDatabase loadCategoryDatabase = LoadCategoryDatabase.DeserializeResource(code); loadCategoryDatabase.End = ""; return(loadCategoryDatabase); }
/// <summary> /// Deserialize LoadCategoryDatabase from embedded resource. /// </summary> private static LoadCategoryDatabase DeserializeResource(string countryCode) { XmlSerializer deserializer = new XmlSerializer(typeof(LoadCategoryDatabase)); Assembly assembly = Assembly.GetExecutingAssembly(); foreach (string resourceName in assembly.GetManifestResourceNames()) { if (resourceName.EndsWith("loadCoefficients_" + countryCode + ".struxml")) { using (Stream stream = assembly.GetManifestResourceStream(resourceName)) { TextReader reader = new StreamReader(stream); object obj = deserializer.Deserialize(reader); LoadCategoryDatabase loadCategoryDatabase = (LoadCategoryDatabase)obj; reader.Close(); return(loadCategoryDatabase); } } } throw new System.ArgumentException("Load coefficient library resource not in assembly! Was solution compiled without embedded resources?"); }