Beispiel #1
0
        /// <summary>
        /// Reads and validates each line of config file
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="devices"></param>
        /// <param name="WriteLog"></param>
        internal static void ReadFile(string filePath, ref List <Device> devices, Action <string, int> WriteLog)
        {
            string[] lines = File.ReadAllLines(filePath);

            int deviceNumber = 1;

            string deviceType = null;

            Dictionary <string, string> deviceInfo = new Dictionary <string, string>();

            foreach (string line in lines)
            {
                if (ConfigFilesMediator.IgnoreLine(line))
                {
                    if (deviceType != null)
                    {
                        CreateDevice(ref devices, deviceType, deviceInfo, ref deviceNumber, WriteLog);

                        deviceType = null;
                        deviceInfo.Clear();
                    }

                    continue;
                }

                LineValidations(ref deviceType, line);

                ReadLine(line, deviceInfo);
            }

            if (deviceType != null)
            {
                CreateDevice(ref devices, deviceType, deviceInfo, ref deviceNumber, WriteLog);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Reads and validates each line of config file
        /// </summary>
        /// <param name="filePath"></param>
        internal static void ReadFile(string filePath)
        {
            string[] lines = File.ReadAllLines(filePath);

            string        dataSetLabel = null;
            List <string> epcs         = new List <string>();

            foreach (string line in lines)
            {
                if (ConfigFilesMediator.IgnoreLine(line))
                {
                    if (dataSetLabel != null)
                    {
                        EPCsComparer.AddDataSet(dataSetLabel, epcs.ToList());

                        dataSetLabel = null;
                        epcs.Clear();
                    }

                    continue;
                }

                LineValidations(ref dataSetLabel, line);

                ReadLine(line, epcs);
            }

            if (dataSetLabel != null)
            {
                EPCsComparer.AddDataSet(dataSetLabel, epcs);
            }
        }
        /// <summary>
        /// Reads and validates each line of config file
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="notes"></param>
        internal static void ReadFile(string filePath, ref string notes)
        {
            string[] lines = File.ReadAllLines(filePath);

            bool gotAnyText = false;

            foreach (string line in lines)
            {
                if (ConfigFilesMediator.IgnoreLine(line))
                {
                    continue;
                }

                LineValidations(line);

                gotAnyText = true;

                notes += ReadLine(line);
            }

            if (!gotAnyText)
            {
                throw new Exception("Notes file doesn't have any notes");
            }
        }
        /// <summary>
        /// Reads and validates each line of config file
        /// </summary>
        /// <param name="filePath"></param>
        internal static void ReadFile(string filePath)
        {
            string[] lines = File.ReadAllLines(filePath);

            foreach (string line in lines)
            {
                if (ConfigFilesMediator.IgnoreLine(line))
                {
                    continue;
                }

                LineValidations(line);

                ReadLine(line);
            }
        }
        /// <summary>
        /// Reads and validates each line of config file
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="tableName"></param>
        /// <param name="connStr"></param>
        internal static void ReadFile(string filePath, ref string tableName, ref string connStr)
        {
            /// string array with each line's value
            string[] connStrArr = new string[5];

            string[] lines = File.ReadAllLines(filePath);

            foreach (string line in lines)
            {
                if (ConfigFilesMediator.IgnoreLine(line))
                {
                    continue;
                }

                LineValidations(line);

                ReadLine(line, ref connStrArr, ref tableName);
            }

            /// transfroms string array into a string, separating each element with a ';'
            connStr = string.Join(";", connStrArr);
        }