예제 #1
0
        private static List <string> GetPathsFromFile(string fileName)
        {
            var paths = new List <string>();

            try
            {
                var iniManager = new IniManager(fileName);
                var count      = Convert.ToInt32(iniManager.ReadValue(MtbSectionKey, MtbNumFilesKey));
                for (int i = 1; i <= count; i++)
                {
                    var key  = string.Format("File{0}", i);
                    var path = iniManager.ReadValue(MtbSectionKey, key);

                    string testFileName = path.Split(';')[0];

                    if (!Directory.Exists(testFileName))
                    {
                        string line = string.Format(Resources.GeneralFileNotFound, testFileName);
                        ConsoleWriter.WriteLine(line);
                        ConsoleWriter.ErrorSummaryLines.Add(line);
                        Launcher.ExitCode = Launcher.ExitCodeEnum.Failed;
                    }
                    else
                    {
                        paths.Add(testFileName);
                    }
                }
            }
            //The given file is not a valid mtb file
            catch { }

            return(paths);
        }
        private static List<string> GetPathsFromFile(string fileName)
        {
            var paths = new List<string>();
            try
            {
                var iniManager = new IniManager(fileName);
                var count = Convert.ToInt32(iniManager.ReadValue(MtbSectionKey, MtbNumFilesKey));
                for (int i = 1; i <= count; i++)
                {
                    var key = string.Format("File{0}", i);
                    var path = iniManager.ReadValue(MtbSectionKey, key);

                    string testFileName = path.Split(';')[0];

                    if (!Directory.Exists(testFileName))
                    {
                        string line = string.Format(Resources.GeneralFileNotFound, testFileName);
                        ConsoleWriter.WriteLine(line);
                        ConsoleWriter.ErrorSummaryLines.Add(line);
                        Launcher.ExitCode = Launcher.ExitCodeEnum.Failed;
                    }
                    else
                    {
                        paths.Add(testFileName);
                    }
                }
            }
            //The given file is not a valid mtb file
            catch { }

            return paths;
        }
        public static Dictionary <string, Dictionary <string, string> > LoadIniFileAsDictionary(string strFileName)
        {
            Dictionary <string, Dictionary <string, string> > retVal = new Dictionary <string, Dictionary <string, string> >();
            IniManager man = new IniManager(strFileName);

            foreach (string sect in man.GetSectionNames())
            {
                retVal.Add(sect, man.GetSectionAsDictionary(sect));
            }
            return(retVal);
        }
        /// <summary>
        /// Save the contents to a file in the file system
        /// </summary>
        /// <param name="paths"></param>
        public void Save(IEnumerable<string> paths)
        {
            var count = paths.Count();
            var iniManager = new IniManager(_mtbFileName);
            iniManager.WriteValue(MtbSectionKey, MtbNumFilesKey, count.ToString());

            int i = 1;
            foreach (var path in paths)
            {
                var key = string.Format("File{0}", i++);
                var value = string.Format("{0};1", path);
                iniManager.WriteValue(MtbSectionKey, key, value);
            }
        }
예제 #5
0
        /// <summary>
        /// Save the contents to a file in the file system
        /// </summary>
        /// <param name="paths"></param>
        public void Save(IEnumerable <string> paths)
        {
            var count      = paths.Count();
            var iniManager = new IniManager(_mtbFileName);

            iniManager.WriteValue(MtbSectionKey, MtbNumFilesKey, count.ToString());

            int i = 1;

            foreach (var path in paths)
            {
                var key   = string.Format("File{0}", i++);
                var value = string.Format("{0};1", path);
                iniManager.WriteValue(MtbSectionKey, key, value);
            }
        }
        public void TestIniFile()
        {
            try
            {
                IniManager m = new IniManager(testIniFile);
                HashSet<string> sects = m.GetSectionNames();
                HashSet<string> fileEnts = m.GetEntryNames("Files");
                Dictionary<string, string> FilesDict = m.GetSectionAsDictionary("Files");
                Dictionary<string, string> Test1Dict = m.GetSectionAsDictionary("Test1");
                Dictionary<string, string> Test2Dict = m.GetSectionAsDictionary("Test2");
                var dict = IniManager.LoadIniFileAsDictionary(testIniFile);

                Assert.IsTrue(FilesDict.Count > 0);
                Assert.IsTrue(Test1Dict.Count > 0);
                Assert.IsTrue(dict.Count > 0);
            }
            catch
            {
                Assert.Fail();
            }
        }
 public static Dictionary<string, Dictionary<string,string>> LoadIniFileAsDictionary(string strFileName)
 {
     Dictionary<string, Dictionary<string, string>> retVal = new Dictionary<string, Dictionary<string, string>>();
     IniManager man = new IniManager(strFileName);
     foreach (string sect in man.GetSectionNames())
     {
         retVal.Add(sect, man.GetSectionAsDictionary(sect));
     }
     return retVal;
 }