Example #1
0
        private static DemoDetail ReadDetails(string path)
        {
            if (path == null)
            {
                return null;
            }

            var name = string.Empty;
            var icon = string.Empty;
            var description = "No description provided.";

            var tagParser = new PropertyTagParser(File.ReadAllLines(path));
            Tuple<string, string> tag;
            var flag = false;
            while((tag = tagParser.GetNextTag()) != null)
            {
                switch(tag.Item1)
                {
                case "name":
                    name = tag.Item2;
                    flag = true;
                    break;
                case "icon":
                    icon = tag.Item2;
                    break;
                case "description":
                    description = tag.Item2;
                    break;
                }
            }

            return flag ? new DemoDetail { FileName = Path.GetFileName(path), Path = path, Name = name, Icon = icon, Description = description } : null;
        }
Example #2
0
        private static Platform[] LoadPlatforms()
        {
            var    platformList = new List <Platform>();
            string scriptsPath  = Directory.GetCurrentDirectory() + "/platforms/boards";

            foreach (var fileName in Directory.EnumerateFiles(scriptsPath))
            {
                var tagParser = new PropertyTagParser(File.ReadAllLines(fileName));
                var platform  = new Platform();
                Tuple <string, string> tag;

                while ((tag = tagParser.GetNextTag()) != null)
                {
                    bool val;
                    switch (tag.Item1.ToLower())
                    {
                    case Name:
                        platform.Name = tag.Item2;
                        break;

                    case IconResource:
                        platform.IconResource = tag.Item2;
                        break;

                    case HasPendrive:
                        if (!bool.TryParse(tag.Item2, out val))
                        {
                            break;
                        }
                        platform.HasPendrive = val;
                        break;

                    case HasFlash:
                        if (!bool.TryParse(tag.Item2, out val))
                        {
                            break;
                        }
                        platform.HasFlash = val;
                        break;
                    }
                }

                if (string.IsNullOrEmpty(platform.Name))
                {
                    continue;
                }

                platform.ScriptPath = fileName;
                platformList.Add(platform);
            }

            return(platformList.ToArray <Platform>());
        }
Example #3
0
        private static Platform[] LoadPlatforms()
        {
            var platformList = new List<Platform>();
            string scriptsPath = Directory.GetCurrentDirectory() + "/platforms/boards";

            foreach(var fileName in Directory.EnumerateFiles(scriptsPath))
            {
                var tagParser = new PropertyTagParser(File.ReadAllLines(fileName));
                var platform = new Platform();
                Tuple<string, string> tag;

                while((tag = tagParser.GetNextTag()) != null)
                {
                    bool val;
                    switch(tag.Item1.ToLower())
                    {
                    case Name:
                        platform.Name = tag.Item2;
                        break;
                    case IconResource:
                        platform.IconResource = tag.Item2;
                        break;
                    case HasPendrive:
                        if(!bool.TryParse(tag.Item2, out val))
                        {
                            break;
                        }
                        platform.HasPendrive = val;
                        break;
                    case HasFlash:
                        if(!bool.TryParse(tag.Item2, out val))
                        {
                            break;
                        }
                        platform.HasFlash = val;
                        break;
                    }
                }

                if(string.IsNullOrEmpty(platform.Name))
                {
                    continue;
                }

                platform.ScriptPath = fileName;
                platformList.Add(platform);
            }

            return platformList.ToArray<Platform>();
        }