IOsbideEvent IOsbideEvent.FromDict(Dictionary <string, object> values) { CutCopyPasteEvent evt = new CutCopyPasteEvent(); if (values.ContainsKey("Id")) { evt.Id = (int)values["Id"]; } if (values.ContainsKey("EventLogId")) { evt.EventLogId = (int)values["EventLogId"]; } if (values.ContainsKey("EventLog")) { evt.EventLog = (EventLog)values["EventLog"]; } if (values.ContainsKey("EventDate")) { evt.EventDate = (DateTime)values["EventDate"]; } if (values.ContainsKey("SolutionName")) { evt.SolutionName = values["SolutionName"].ToString(); } if (values.ContainsKey("EventAction")) { evt.EventAction = (int)values["EventAction"]; } if (values.ContainsKey("Content")) { evt.Content = values["Content"].ToString(); } return(evt); }
public static IOsbideEvent FromCommand(string commandName, DTE2 dte) { IOsbideEvent oEvent = null; //debugging events if (debugCommands.Contains(commandName)) { DebugActions action = (DebugActions)debugCommands.IndexOf(commandName); DebugEvent debug = new DebugEvent(); debug.SolutionName = dte.Solution.FullName; debug.EventDate = DateTime.UtcNow; //sometimes document name can be null try { debug.DocumentName = dte.ActiveDocument.Name; } catch (Exception) { debug.DocumentName = dte.Solution.FullName; } //add line number if applicable if (action == DebugActions.StepInto || action == DebugActions.StepOut || action == DebugActions.StepOver ) { //line number can be null if there is no document open try { TextSelection debugSelection = dte.ActiveDocument.Selection; debugSelection.SelectLine(); int lineNumber = debugSelection.CurrentLine; debug.LineNumber = lineNumber; debug.DebugOutput = debugSelection.Text; } catch (Exception) { debug.LineNumber = 0; } } //kind of reappropriating this for our current use. Consider refactoring. debug.ExecutionAction = (int)action; //throw the content of the output window into the event if we just stopped debugging if (action == DebugActions.StopDebugging) { OutputWindowPane debugWindow = dte.ToolWindows.OutputWindow.OutputWindowPanes.Item("Debug"); if (debugWindow != null) { TextDocument text = debugWindow.TextDocument; TextSelection selection = text.Selection; selection.StartOfDocument(); selection.EndOfDocument(true); debug.DebugOutput = selection.Text; selection.EndOfDocument(); } } oEvent = debug; } else if (cutCopyPasteCommands.Contains(commandName)) { CutCopyPasteEvent ccp = new CutCopyPasteEvent(); ccp.SolutionName = dte.Solution.FullName; ccp.EventDate = DateTime.UtcNow; ccp.EventAction = cutCopyPasteCommands.IndexOf(commandName); ccp.Content = Clipboard.GetText(); //sometimes document name can be null try { ccp.DocumentName = dte.ActiveDocument.Name; } catch (Exception) { ccp.DocumentName = dte.Solution.FullName; } oEvent = ccp; } return(oEvent); }