예제 #1
0
        public string CreateAndLoadScript()
        {
            string scriptFile   = CSScriptViewModel.GenerateNewScriptVSSolution();
            string solutionFile = CSScriptViewModel.GenerateScriptVSSolution(scriptFile);

            Utils.GetDTE().Solution.Open(solutionFile);
            //Utils.GetDTE().ExecuteCommand("File.OpenFile", "\"" + scriptFile + "\"");
            Utils.GetDTE().ItemOperations.OpenFile(scriptFile); //zos
            return(solutionFile);
        }
예제 #2
0
        public void OpenScript(string file)
        {
            string prevSolutionFile = Utils.GetDTE().Solution.FileName;
            string solutionFile     = CSScriptViewModel.GenerateScriptVSSolution(file);

            //RecentFilesHelper.Instance.Synch(project, scriptFile);

            Utils.GetDTE().Solution.Open(solutionFile);
            //Utils.GetDTE().ExecuteCommand("File.OpenFile", "\"" + file + "\"");
            Utils.GetDTE().ItemOperations.OpenFile(file);

            ReleaseSolution(prevSolutionFile);
            LockSolution(solutionFile);
        }
예제 #3
0
 private void Config_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     SafeInvoke(() =>
                System.Diagnostics.Process.Start(System.IO.Path.Combine(CSScriptViewModel.GetCSScriptHomeDir(), "css_config.exe")));
 }
예제 #4
0
 private void AppData_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     SafeInvoke(() =>
                System.Diagnostics.Process.Start("explorer.exe", "/e,\"" + CSScriptViewModel.GetTempScriptsDir() + "\""));
 }
예제 #5
0
 private void Samples_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     SafeInvoke(() =>
                System.Diagnostics.Process.Start("explorer.exe", "/e,/select,\"" + System.IO.Path.Combine(CSScriptViewModel.GetCSScriptHomeDir(), "Samples\\Hello.cs") + "\""));
 }
예제 #6
0
        void Synch(string scriptFile)
        {
            ExecuteInGUIThread(() =>
            {
                Project project = Utils.GetActiveProject();

                Dictionary <string, List <string> > expectedDependencies = CSScriptViewModel.GetScriptDependencies(scriptFile);

                string[] expectedSources = expectedDependencies["src"]
                                           .ToArray();

                var expectedReferences = expectedDependencies["asm"]
                                         .Select((file) => new
                {
                    Name = Path.GetFileName(file).ToLower(),
                    File = file
                })
                                         .ToArray();

                string[] actualSources    = project.GetSources();
                string[] actualReferences = project.GetReferences()
                                            .Select((file) => Path.GetFileName(file).ToLower())
                                            .ToArray();

                //source files
                foreach (string expectsdSource in expectedSources)
                {
                    if (!actualSources.Contains(expectsdSource))
                    {
                        project.AddFile(expectsdSource);
                    }
                }

                foreach (string actualSource in actualSources)
                {
                    if (!expectedSources.Contains(actualSource))
                    {
                        project.RemoveFile(actualSource);
                    }
                }

                //referenced assemblies
                foreach (var expectsdAsm in expectedReferences)
                {
                    if (!actualReferences.Contains(expectsdAsm.Name))
                    {
                        project.AddReference(expectsdAsm.File);
                    }
                }

                foreach (string actualAsm in actualReferences)
                {
                    if (string.Compare(actualAsm, "System.dll", true) == 0 ||
                        string.Compare(actualAsm, "mscorlib.dll", true) == 0 ||
                        string.Compare(actualAsm, "System.Core.dll", true) == 0)
                    {
                        continue;
                    }

                    bool found = false;
                    foreach (var item in expectedReferences)
                    {
                        if (item.Name == actualAsm)
                        {
                            found = true;
                        }
                    }

                    if (!found)
                    {
                        project.RemoveReference(actualAsm);
                    }
                }
            });
        }