Exemplo n.º 1
0
        public static int GetCurrentLine(this ISEFile iseFile)
        {
            var getCurrentLineMethod = iseFile.GetType().GetMethod("GetCurrentLine", BindingFlags.NonPublic | BindingFlags.Instance);

            var currentLine = (int)getCurrentLineMethod.Invoke(iseFile, null);

            return(currentLine);
        }
Exemplo n.º 2
0
        public static List <LineBreakpoint> GetBreakpointsAtLine(this ISEFile iseFile, int currentLine)
        {
            var getBreakpointsAtLineMethod = iseFile.GetType().GetMethod("GetBreakpointsAtLine", BindingFlags.Instance | BindingFlags.NonPublic);

            var breakpoints = getBreakpointsAtLineMethod.Invoke(iseFile, new object[] { currentLine }) as List <LineBreakpoint>;

            return(breakpoints);
        }
 public IseFileWatcher(FileSystemChangeNotifier fileSystemChangeNotifier, string path, ISEFile iseFile)
 {
     this.iseFile = iseFile;
     this.fileSystemChangeNotifier = fileSystemChangeNotifier;
     this.watcher = new FileSystemWatcher(Path.GetDirectoryName(path), Path.GetFileName(path));
     this.watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.CreationTime | NotifyFilters.Security;
     this.watcher.Changed += OnFileChanged;
     this.watcher.Deleted += OnFileChanged;
     this.watcher.Renamed += OnFileRenamed;
     this.watcher.EnableRaisingEvents = true;
 }
Exemplo n.º 4
0
        public FunctionExplorer()
        {
            InitializeComponent();

            var                     iseWindow       = Application.Current.MainWindow;
            FieldInfo               tabControlField = iseWindow.GetType().GetField("runspaceTabControl", BindingFlags.Instance | BindingFlags.NonPublic);
            RunspaceTabControl      tabControl      = (RunspaceTabControl)tabControlField.GetValue(iseWindow);
            PowerShellTabCollection tabCollection   = tabControl.ItemsSource as PowerShellTabCollection;
            ISEFile                 file            = tabCollection.SelectedPowerShellTab.Files.SelectedFile;
            ISEEditor               editor          = file.Editor;

            var mainMenuField = iseWindow.GetType().GetField("mainMenu", BindingFlags.Instance | BindingFlags.NonPublic);
            var mainMenu      = (Menu)mainMenuField.GetValue(iseWindow);

            var newItem = new MenuItem();

            newItem.Header = "Open Solution";

            //((MenuItem)mainMenu.Items[0]).Items.Add(newItem);
            ((MenuItem)mainMenu.Items[0]).Items.Insert(2, newItem);


            var x = hostObject;



            fileManager.Add(functionsFileName);
            fileManager.Add(openFilesFileName);
            fileManager.Add(breakPointsFileName);
            fileManager.Add(debugLogfileName);

            AppDomain.CurrentDomain.DomainUnload         += CurrentDomain_ProcessExit;
            AppDomain.CurrentDomain.ProcessExit          += CurrentDomain_ProcessExit;
            AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException;

            try
            {
                sw = new System.IO.StreamWriter(fileManager.Get(debugLogfileName).FullName, true);
            }
            catch { }

            statusBarMessage = (System.Windows.Controls.Primitives.StatusBarItem) this.stbBottom.Items[1];
            statusBarContent = (System.Windows.Controls.Primitives.StatusBarItem) this.stbBottom.Items[0];

            timer       = new DispatcherTimer();
            timer.Tick += new EventHandler(timer_Tick);

            updateTimer       = new DispatcherTimer();
            updateTimer.Tick += new EventHandler(updateTimer_Tick);
            txtUpdateInterval_LostFocus(null, null); //start the timer with the value set in the form
        }
Exemplo n.º 5
0
        public static string GetContentHash(this ISEFile iseFile)
        {
            byte[] textBytes = Encoding.UTF8.GetBytes(iseFile.Editor.Text);

            MD5 md5 = new MD5CryptoServiceProvider();

            byte[] retVal = md5.ComputeHash(textBytes);

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < retVal.Length; i++)
            {
                sb.Append(retVal[i].ToString("x2"));
            }
            return(sb.ToString());
        }
Exemplo n.º 6
0
        public static string SaveFile(string directoryPath, string name, string id, string content, ISEFile newFile)
        {
            string filePath = System.IO.Path.Combine(directoryPath, name);

			if (FileNotStoredLocally(filePath))
            {
				//create the directory if needed
                CreateDirIfNeeded(directoryPath);
            }
			else if (HasLocalchanges(content, filePath) && !OverwriteLocalChanges(filePath))
			{
				//No override wanted so we'll just return the file
				return filePath;
			}

			//Save the file locally and return the path
			return SaveFileLocally(newFile, filePath);
		}
 public void StopWatching()
 {
     this.watcher.EnableRaisingEvents = false;
     this.iseFile = null;
 }
Exemplo n.º 8
0
 private static string SaveFileLocally(ISEFile newFile, string filePath)
 {
     newFile.SaveAs(filePath);
     return filePath;
 }