Example #1
0
 void Initialize()
 {
     initialized = true;
     tags.Clear();
     foreach (IStringTagProvider provider in StringParserService.GetProviders())
     {
         foreach (object obj in objects)
         {
             if (obj is StringTagModel)
             {
                 continue;
             }
             foreach (StringTagDescription tag in provider.GetTags(obj.GetType()))
             {
                 if (!tags.ContainsKey(tag.Name))
                 {
                     tag.SetSource(provider, obj);
                     tags.Add(tag.Name, tag);
                 }
             }
         }
         foreach (StringTagDescription tag in provider.GetTags(null))
         {
             if (!tags.ContainsKey(tag.Name))
             {
                 tag.SetSource(provider, null);
                 tags.Add(tag.Name, tag);
             }
         }
     }
     foreach (object obj in objects)
     {
         StringTagModel source = obj as StringTagModel;
         if (source == null)
         {
             continue;
         }
         foreach (var tag in source.Tags.Values)
         {
             if (!tags.ContainsKey(tag.Name))
             {
                 tags.Add(tag.Name, tag);
             }
         }
     }
 }
Example #2
0
		public void Execute (IProgressMonitor monitor, IWorkspaceObject entry, ExecutionContext context, ConfigurationSelector configuration)
		{
			StringTagModel tagSource;
			
			if (entry is SolutionItem)
				tagSource = ((SolutionItem)entry).GetStringTagModel (configuration);
			else if (entry is WorkspaceItem)
				tagSource = ((WorkspaceItem)entry).GetStringTagModel ();
			else
				tagSource = new StringTagModel ();
			
			if (string.IsNullOrEmpty (command))
				return;
			
			int i = command.IndexOf (' ');
			string exe;
			string args = string.Empty;
			if (i == -1) {
				exe = StringParserService.Parse (command, tagSource);
				args = string.Empty;
			} else {
				exe = StringParserService.Parse (command.Substring (0, i), tagSource);
				args = StringParserService.Parse (command.Substring (i + 1), tagSource);
			}
			
			monitor.Log.WriteLine (GettextCatalog.GetString ("Executing: {0} {1}", exe, args));

			FilePath dir = (string.IsNullOrEmpty (workingdir) ? entry.BaseDirectory : (FilePath) StringParserService.Parse (workingdir, tagSource));

			FilePath localPath = entry.BaseDirectory.Combine (exe);
			if (File.Exists (localPath))
				exe = localPath;
			
			IProcessAsyncOperation oper;
			
			if (context != null) {
				IConsole console;
				if (externalConsole)
					console = context.ExternalConsoleFactory.CreateConsole (!pauseExternalConsole);
				else
					console = context.ConsoleFactory.CreateConsole (!pauseExternalConsole);

				ExecutionCommand cmd = Runtime.ProcessService.CreateCommand (exe);
				ProcessExecutionCommand pcmd = cmd as ProcessExecutionCommand;
				if (pcmd != null) {
					pcmd.Arguments = args;
					pcmd.WorkingDirectory = dir;
				}
				oper = context.ExecutionHandler.Execute (cmd, console);
			}
			else {
				if (externalConsole) {
					IConsole console = ExternalConsoleFactory.Instance.CreateConsole (!pauseExternalConsole);
					oper = Runtime.ProcessService.StartConsoleProcess (exe, args, dir, console, null);
				} else {
					oper = Runtime.ProcessService.StartProcess (exe, args, dir, monitor.Log, monitor.Log, null, false);
				}
			}
			
			monitor.CancelRequested += delegate {
				if (!oper.IsCompleted)
					oper.Cancel ();
			};
			
			oper.WaitForCompleted ();
			if (!oper.Success) {
				monitor.ReportError ("Custom command failed (exit code: " + oper.ExitCode + ")", null);
				monitor.AsyncOperation.Cancel ();
			}
		}
Example #3
0
 public void Add(StringTagModel source)
 {
     objects.Add(source);
     initialized = false;
 }
Example #4
0
		void ParseCommand (StringTagModel tagSource, out string cmd, out string args)
		{
			if (command.Length > 0 && command [0] == '"') {
				int n = command.IndexOf ('"', 1);
				if (n != -1) {
					cmd = command.Substring (1, n - 1);
					args = command.Substring (n + 1).Trim ();
				}
				else {
					cmd = command;
					args = string.Empty;
				}
			}
			else {
				int i = command.IndexOf (' ');
				if (i != -1) {
					cmd = command.Substring (0, i);
					args = command.Substring (i + 1).Trim ();
				} else {
					cmd = command;
					args = string.Empty;
				}
			}
			cmd = StringParserService.Parse (cmd, tagSource);
			args = StringParserService.Parse (args, tagSource);
		}
		void ParseCommand (StringTagModel tagSource, out string cmd, out string args)
		{
			ParseCommand (out cmd, out args);
			cmd = StringParserService.Parse (cmd, tagSource);
			args = StringParserService.Parse (args, tagSource);
		}
Example #6
0
		public void Add (StringTagModel source)
		{
			objects.Add (source);
			initialized = false;
		}