Exemplo n.º 1
0
        private static Stream LoadCsvStream(StaticDataType type)
        {
            var assembly = Assembly.GetExecutingAssembly();

            var resourceName = string.Format("Common.static_data.{0}.txt", type.ToString().ToLower());

            return(assembly.GetManifestResourceStream(resourceName));
        }
Exemplo n.º 2
0
        public EoiDataType(StaticDataType staticType)
        {
            if (staticType == null)
            {
                Invalid = true;
                return;
            }

            _staticType = staticType;

            Id = staticType.Id;
        }
Exemplo n.º 3
0
        private static IEnumerable <T> GetStaticData <T>(StaticDataType type, Func <string, T> factory)
        {
            using (var strm = LoadCsvStream(type))
                using (var reader = new StreamReader(strm))
                {
                    reader.ReadLine(); // skip header

                    var line = reader.ReadLine();

                    while (!string.IsNullOrWhiteSpace(line))
                    {
                        yield return(factory(line));

                        line = reader.ReadLine();
                    }
                }
        }
Exemplo n.º 4
0
 internal static EoiDataType GetType(StaticDataType product)
 {
     return(_eoiDataTypes.FirstOrDefault(x => Equals(product, x.GetStaticType())));
 }