public static void Load<T>(string filename, List<T> listToAdd, string folder = null) where T : IGetTypeObject
        {
            listToAdd.Clear();
            string projectFileName;

            if (folder != null)
                projectFileName = folder + "\\" + filename;
            else
                projectFileName = filename;

            List<T> listT = new List<T>();
            listT = ReadFile.GetObjects<T>(projectFileName, Properties.Value);
            listToAdd.AddRange(listT);
        }
Exemple #2
0
        public static Type GetTypeObject(string line, string[] headersEn)
        {
            string[] lines    = ReadFile.GetSplitString(line);
            var      propName = typeof(IGetTypeEnumObject <int>).GetProperties();

            for (int i = 0; i < headersEn.Length; i++)
            {
                if (headersEn[i] != null && headersEn[i].Equals(propName[0].Name))
                {
                    Enum key = Value.First(x => x.Value.Name == lines[i].Trim()).Key;
                    return(Value[key].SystemType);
                }
            }
            return(null);
        }
        public static List<T> GetObjects<T>(string filename, Dictionary<string, string> headRuEn) where T : IGetTypeObject
        {
            List<T> listT = new List<T>();

            var lines = File.ReadAllLines(filename, Encoding.Default).ToList();
            var headersRus = lines.First();
            string[] headersRu = GetSplitString(headersRus);
            lines.RemoveAt(0);
            string[] headersEn = ReadFile.GetEnHeaders(headersRus, headRuEn);

            foreach (var line in lines)
            {
                Type type = TypeObject.GetTypeObject(line, headersEn);
                if (type != null)
                {
                    T obj = ReadFile.CreateType<T>(line, headersEn, headersRu, type);
                    obj.GetTypeObject = TypeObject.GetTypeObject;
                    listT.Add(obj);
                }
            }
            return listT;
        }