Exemplo n.º 1
0
        public static Project FromFile(string file)
        {
            var project = new Project();
            project.Values = new Dictionary<string, string>();
            project.File = file;
            project.RootDirectory = Path.GetDirectoryName(file);

            // Open and parse project config
            Stack<bool> conditions = new Stack<bool>();
            conditions.Push(true);
            using (var reader = new StreamReader(file))
            {
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    line = line.Trim();
                    if (line.StartsWith("#"))
                        continue;
                    if (line.StartsWith("@"))
                    {
                        if (line.ToUpper() == "@END")
                            conditions.Pop();
                        if (line.ToUpper().StartsWith("@IF "))
                        {
                            // TODO: Make this better
                            conditions.Push(line.ToUpper().Substring(3).Trim() == "WINDOWS");
                        }
                    }
                    if (!line.Contains("=") || !conditions.Peek())
                        continue;
                    var key = line.Remove(line.IndexOf('='));
                    var value = line.Substring(line.IndexOf('=') + 1);
                    project.Values[key] = value;
                }
            }
            return project;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Opens a project and adjusts the enviornment to use it.
 /// </summary>
 public void OpenProject(Project project)
 {
     FileBrowser = new FileBrowser(project.RootDirectory);
     FileBrowser.Show(dockingManager, AnchorStyle.Left);
     FileBrowser.OpenFile += (s, e) => OpenFile(e.File);
     CurrentProject = project;
     StartPage.Close();
     Title = project.Name + " - Halibut";
     var watcher = new FileSystemWatcher(Path.GetDirectoryName(project.File), Path.GetFileName(project.File));
     watcher.Changed += (s, e) => ReloadProject();
     watcher.EnableRaisingEvents = true;
     RecentProjects.ProjectOpened(project);
 }