Пример #1
0
        void SelectActiveRuntime()
        {
            runtimeCombo.Changed -= HandleRuntimeChanged;

            try {
                TreeIter iter;

                if (runtimeStore.GetIterFirst(out iter))
                {
                    ExecutionTarget defaultTarget = null;
                    TreeIter        defaultIter   = TreeIter.Zero;
                    bool            selected      = false;

                    if (!SelectActiveRuntime(iter, ref selected, ref defaultTarget, ref defaultIter) && !selected)
                    {
                        if (defaultTarget != null)
                        {
                            IdeApp.Workspace.ActiveExecutionTarget = defaultTarget;
                            runtimeCombo.SetActiveIter(defaultIter);
                        }
                        UpdateBuildConfiguration();
                    }
                }
            } finally {
                runtimeCombo.Changed += HandleRuntimeChanged;
            }
        }
Пример #2
0
        void SelectActiveRuntime()
        {
            ignoreRuntimeChangedCount++;

            try {
                if (ToolbarView.RuntimeModel.Any())
                {
                    ExecutionTarget defaultTarget = null;
                    bool            selected      = false;
                    int             defaultIter   = 0;

                    if (!SelectActiveRuntime(ref selected, ref defaultTarget, ref defaultIter) && !selected)
                    {
                        if (defaultTarget != null)
                        {
                            IdeApp.Workspace.ActiveExecutionTarget = defaultTarget;
                            ToolbarView.ActiveRuntime = ToolbarView.RuntimeModel.ElementAt(defaultIter);
                        }
                        UpdateBuildConfiguration();
                    }
                }
            } finally {
                ignoreRuntimeChangedCount--;
            }
        }
        public static async Task LaunchBrowserAsync(string appUrl, string launchUrl, ExecutionTarget target, Task processTask)
        {
            launchUrl = launchUrl ?? "";
            Uri launchUri;

            //Check if lanuchUrl is valid absolute url and use it if it is...
            if (!Uri.TryCreate(launchUrl, UriKind.Absolute, out launchUri))
            {
                //Otherwise check if appUrl is valid absolute and lanuchUrl is relative then concat them...
                Uri appUri;
                if (!Uri.TryCreate(appUrl, UriKind.Absolute, out appUri))
                {
                    LoggingService.LogWarning("Failed to launch browser because invalid launch and app urls.");
                    return;
                }
                if (!Uri.TryCreate(launchUrl, UriKind.Relative, out launchUri))
                {
                    LoggingService.LogWarning("Failed to launch browser because invalid launch url.");
                    return;
                }
                launchUri = new Uri(appUri, launchUri);
            }

            //Try to connect every 50ms while process is running
            while (!processTask.IsCompleted)
            {
                await Task.Delay(50).ConfigureAwait(false);

                using (var tcpClient = new TcpClient()) {
                    try {
                        await tcpClient.ConnectAsync(launchUri.Host, launchUri.Port).ConfigureAwait(false);

                        // pause briefly to allow the server process to initialize
                        await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);

                        break;
                    } catch {
                    }
                }
            }

            if (processTask.IsCompleted)
            {
                LoggingService.LogDebug("Failed to launch browser because process exited before server started listening.");
                return;
            }

            // Process is still alive hence we succesfully connected inside loop to web server, launch browser
            var aspNetCoreTarget = target as AspNetCoreExecutionTarget;

            if (aspNetCoreTarget != null && !aspNetCoreTarget.DesktopApplication.IsDefault)
            {
                aspNetCoreTarget.DesktopApplication.Launch(launchUri.AbsoluteUri);
            }
            else
            {
                IdeServices.DesktopService.ShowUrl(launchUri.AbsoluteUri);
            }
        }
Пример #4
0
 public static FunctionDeployedPackage DeployFunction(
     FunctionBuiltPackage builtPackage,
     ExecutionTarget target,
     ExecutionContext context)
 {
     context.LoadFunction(builtPackage.Module);
     return(new FunctionDeployedPackage(builtPackage.RuntimeEntityIdentity, target, context));
 }
Пример #5
0
        bool SelectActiveRuntime(ref bool selected, ref ExecutionTarget defaultTarget, ref int defaultIter)
        {
            var    runtimes = ToolbarView.RuntimeModel.Cast <RuntimeModel> ().ToList();
            string lastRuntimeForProject = currentStartupProject != null?currentStartupProject.UserProperties.GetValue <string> ("PreferredExecutionTarget", defaultValue : null) : null;

            var activeTarget   = IdeApp.Workspace.ActiveExecutionTarget;
            var activeTargetId = activeTarget != null ? activeTarget.Id : null;

            for (int iter = 0; iter < runtimes.Count; ++iter)
            {
                var item = runtimes [iter];
                using (var model = item.GetMutableModel()) {
                    if (!model.Enabled)
                    {
                        continue;
                    }
                }

                var target = item.ExecutionTarget;
                if (target == null || !target.Enabled)
                {
                    continue;
                }

                if (target is ExecutionTargetGroup)
                {
                    if (item.HasChildren)
                    {
                        continue;
                    }
                }

                if (defaultTarget == null || lastRuntimeForProject == target.Id)
                {
                    defaultTarget = target;
                    defaultIter   = iter;
                }

                if (target.Id == activeTargetId)
                {
                    IdeApp.Workspace.ActiveExecutionTarget = target;
                    ToolbarView.ActiveRuntime = ToolbarView.RuntimeModel.ElementAt(iter);
                    UpdateBuildConfiguration();
                    selected = true;
                    return(true);
                }

                if (target.Equals(activeTarget))
                {
                    ToolbarView.ActiveRuntime = ToolbarView.RuntimeModel.ElementAt(iter);
                    UpdateBuildConfiguration();
                    selected = true;
                }
            }

            return(false);
        }
Пример #6
0
 private FunctionDeployedPackage(
     IRuntimeEntityIdentity identity,
     ExecutionTarget executionTarget,
     ExecutionContext context,
     bool isAsync)
 {
     DeployedPackageIdentity = identity;
     Executable = new ExecutableFunction(executionTarget, context, identity, isAsync);
 }
Пример #7
0
 public RuntimeModel(MainToolbarController controller, ExecutionTarget target, bool fullText, SolutionItem project) : this(controller)
 {
     if (target == null)
     {
         throw new ArgumentNullException(nameof(target));
     }
     ExecutionTarget = target;
     this.fullText   = fullText;
     Project         = project;
 }
Пример #8
0
        bool CurrentExecutionTargetIsCoreClr(ExecutionTarget executionTarget)
        {
            var dnxExecutionTarget = executionTarget as DnxExecutionTarget;

            if (dnxExecutionTarget != null)
            {
                return(dnxExecutionTarget.IsCoreClr());
            }
            return(false);
        }
        public static async Task LaunchBrowserAsync(string appUrl, string launchUrl, ExecutionTarget target, Task processTask)
        {
            launchUrl = launchUrl ?? "";
            //Check if launchUrl is valid absolute url and use it if it is...
            if (!Uri.TryCreate(launchUrl, UriKind.Absolute, out var launchUri) || launchUri.IsFile)
            {
                //Otherwise check if appUrl is valid absolute and launchUrl is relative then concat them...
                if (!Uri.TryCreate(appUrl, UriKind.Absolute, out var appUri) || appUri.IsFile)
                {
                    LoggingService.LogWarning("Failed to launch browser because invalid launch and app urls.");
                    return;
                }
                if (!Uri.TryCreate(launchUrl, UriKind.Relative, out launchUri))
                {
                    LoggingService.LogWarning("Failed to launch browser because invalid launch url.");
                    return;
                }
                launchUri = new Uri(appUri, launchUri);
            }

            //Try to connect every 50ms while process is running
            while (!processTask.IsCompleted)
            {
                await Task.Delay(50).ConfigureAwait(false);

                using (var httpClient = HttpClientProvider.CreateHttpClient(launchUri.AbsoluteUri)) {
                    try {
                        using (var response = await httpClient.GetAsync(launchUri.AbsoluteUri, System.Net.Http.HttpCompletionOption.ResponseHeadersRead)) {
                            await Task.Delay(1000).ConfigureAwait(false);

                            break;
                        }
                    } catch {
                    }
                }
            }

            if (processTask.IsCompleted)
            {
                LoggingService.LogDebug("Failed to launch browser because process exited before server started listening.");
                return;
            }

            // Process is still alive hence we succesfully connected inside loop to web server, launch browser
            var aspNetCoreTarget = target as AspNetCoreExecutionTarget;

            if (aspNetCoreTarget != null && !aspNetCoreTarget.DesktopApplication.IsDefault)
            {
                aspNetCoreTarget.DesktopApplication.Launch(launchUri.AbsoluteUri);
            }
            else
            {
                IdeServices.DesktopService.ShowUrl(launchUri.AbsoluteUri);
            }
        }
Пример #10
0
 public RuntimeMutableModel(ExecutionTarget target, bool fullName)
 {
     Enabled = !(target is ExecutionTargetGroup) && target.Enabled;
     Visible = true;
     if (target == null)
         DisplayString = FullDisplayString = string.Empty;
     else {
         FullDisplayString = target.FullName;
         DisplayString = fullName ? target.FullName : target.Name;
     }
 }
Пример #11
0
		static bool ExecutionTargetsContains (IEnumerable<ExecutionTarget> targets, ExecutionTarget desired)
		{
			foreach (var target in targets) {
				if (target == desired)
					return true;

				if ((target is ExecutionTargetGroup) && ExecutionTargetsContains ((ExecutionTargetGroup) target, desired))
					return true;
			}

			return false;
		}
Пример #12
0
        bool SelectActiveRuntime(ref bool selected, ref ExecutionTarget defaultTarget, ref int defaultIter)
        {
            var runtimes = ToolbarView.RuntimeModel.Cast <RuntimeModel> ().ToList();

            for (int iter = 0; iter < runtimes.Count; ++iter)
            {
                var item = runtimes [iter];
                using (var model = item.GetMutableModel()) {
                    if (!model.Enabled)
                    {
                        continue;
                    }
                }

                var target = item.ExecutionTarget;
                if (target == null || !target.Enabled)
                {
                    continue;
                }

                if (target is ExecutionTargetGroup)
                {
                    if (item.HasChildren)
                    {
                        continue;
                    }
                }

                if (defaultTarget == null)
                {
                    defaultTarget = target;
                    defaultIter   = iter;
                }

                if (target.Id == IdeApp.Workspace.PreferredActiveExecutionTarget)
                {
                    IdeApp.Workspace.ActiveExecutionTarget = target;
                    ToolbarView.ActiveRuntime = ToolbarView.RuntimeModel.ElementAt(iter);
                    UpdateBuildConfiguration();
                    selected = true;
                    return(true);
                }

                if (target.Equals(IdeApp.Workspace.ActiveExecutionTarget))
                {
                    ToolbarView.ActiveRuntime = ToolbarView.RuntimeModel.ElementAt(iter);
                    UpdateBuildConfiguration();
                    selected = true;
                }
            }

            return(false);
        }
Пример #13
0
 public RuntimeModel(MainToolbarController controller, ExecutionTarget target, RuntimeModel parent) : this(controller, target)
 {
     if (parent == null)
     {
         HasParent = false;
     }
     else
     {
         HasParent          = true;
         parent.HasChildren = true;
         parent.AddChild(this);
     }
 }
Пример #14
0
        public ExecutionContext(IExecutionHandler executionHandler, OperationConsoleFactory consoleFactory, ExecutionTarget target)
        {
            var targetedHandler = executionHandler as ITargetedExecutionHandler;

            if (targetedHandler != null)
            {
                target = targetedHandler.Target ?? target;
            }

            this.executionHandler = executionHandler;
            this.consoleFactory   = consoleFactory;
            this.executionTarget  = target;
        }
Пример #15
0
        bool SelectActiveRuntime(TreeIter iter, ref bool selected, ref ExecutionTarget defaultTarget, ref TreeIter defaultIter)
        {
            do
            {
                var target = (ExecutionTarget)runtimeStore.GetValue(iter, RuntimeExecutionTarget);

                if (target == null)
                {
                    continue;
                }

                if (target is ExecutionTargetGroup)
                {
                    TreeIter child;

                    if (runtimeStore.IterHasChild(iter) && runtimeStore.IterChildren(out child, iter))
                    {
                        if (SelectActiveRuntime(child, ref selected, ref defaultTarget, ref defaultIter))
                        {
                            return(true);
                        }
                    }

                    continue;
                }

                if (defaultTarget == null)
                {
                    defaultTarget = target;
                    defaultIter   = iter;
                }

                if (target.Id == IdeApp.Workspace.PreferredActiveExecutionTarget)
                {
                    IdeApp.Workspace.ActiveExecutionTarget = target;
                    runtimeCombo.SetActiveIter(iter);
                    UpdateBuildConfiguration();
                    selected = true;
                    return(true);
                }

                if (target.Equals(IdeApp.Workspace.ActiveExecutionTarget))
                {
                    runtimeCombo.SetActiveIter(iter);
                    UpdateBuildConfiguration();
                    selected = true;
                }
            } while (runtimeStore.IterNext(ref iter));

            return(false);
        }
Пример #16
0
        void FillRuntimesForProject(List<RuntimeModel> list, SolutionItem project, ref int runtimes)
        {
            ExecutionTarget previous = null;

            foreach (var target in configurationMergers [project].GetTargetsForConfiguration (IdeApp.Workspace.ActiveConfigurationId, configurationMergers.Count < 2)) {
                if (target is ExecutionTargetGroup) {
                    var devices = (ExecutionTargetGroup)target;

                    if (previous != null)
                        list.Add (new RuntimeModel (this, displayText: null));//Seperator

                    list.Add (new RuntimeModel (this, target, true, project));
                    foreach (var device in devices) {
                        if (device is ExecutionTargetGroup) {
                            var versions = (ExecutionTargetGroup)device;

                            if (versions.Count > 1) {
                                var parent = new RuntimeModel (this, device, true, project) {
                                    IsIndented = true,
                                };
                                list.Add (parent);

                                foreach (var version in versions) {
                                    parent.AddChild (new RuntimeModel (this, version, false, project));
                                    runtimes++;
                                }
                            } else {
                                list.Add (new RuntimeModel (this, versions [0], true, project) {
                                    IsIndented = true,
                                });
                                runtimes++;
                            }
                        } else {
                            list.Add (new RuntimeModel (this, device, true, project) {
                                IsIndented = true,
                            });
                            runtimes++;
                        }
                    }
                } else {
                    if (previous is ExecutionTargetGroup) {
                        list.Add (new RuntimeModel (this, displayText: null));//Seperator
                    }

                    list.Add (new RuntimeModel (this, target, true, project));
                    runtimes++;
                }

                previous = target;
            }
        }
Пример #17
0
 public RuntimeMutableModel(ExecutionTarget target, bool hasParent)
 {
     Enabled = !(target is ExecutionTargetGroup);
     Visible = true;
     if (target == null)
     {
         DisplayString = FullDisplayString = string.Empty;
     }
     else
     {
         FullDisplayString = target.FullName;
         DisplayString     = !hasParent ? target.FullName : target.Name;
     }
 }
Пример #18
0
        protected override void OnProcessOutputSchema(MutableObject newSchema)
        {
            ExecutionTarget.SetValue(
                GenerateExecutionSchema(), newSchema);

            //    ExecutionToMutable(new Execution()
            //{
            //    RequestNature = RequestNature.GetFirstValue( newSchema ),
            //    Traces = new List<Trace>(){Trace.GenerateEmptyTrace()},
            //    CbAuthor = "Author",
            //    ServiceId = new ServiceIdentifier() { Name = "Service Name"},
            //}), newSchema);

            Router.TransmitAllSchema(newSchema);
        }
Пример #19
0
		/// <summary>
		/// Gets the full configuration name given a possibly merged configuration name and execution target
		/// </summary>
		/// <param name='currentConfig'>
		/// A configuration name (can be a merged configuration name)
		/// </param>
		/// <param name='currentTarget'>
		/// Selected execution target
		/// </param>
		/// <param name='resolvedConfig'>
		/// Resolved configuration
		/// </param>
		/// <param name='resolvedTarget'>
		/// If the provided target is not valid for the provided configuration, this returns a valid target
		/// </param>
		public void ResolveConfiguration (string currentConfig, ExecutionTarget currentTarget, out string resolvedConfig, out ExecutionTarget resolvedTarget)
		{
			resolvedConfig = null;
			resolvedTarget = currentTarget;

			if (!reducedConfigurations.Contains (currentConfig)) {
				// The selected configuration is not reduced, just use it as full config name
				resolvedConfig = currentConfig;
				var part = currentTargetPartitions.FirstOrDefault (p => p.SolutionConfigurations.Contains (currentConfig));
				if (part != null) {
					if (!ExecutionTargetsContains (part.Targets, resolvedTarget))
						resolvedTarget = FirstRealExecutionTarget (part.Targets);
				} else {
					resolvedTarget = null;
				}
			} else {
				// Reduced configuration. Find the partition and guess the implicit project configuration
				var part = currentTargetPartitions.FirstOrDefault (p => ExecutionTargetsContains (p.Targets, currentTarget ?? dummyExecutionTarget));
				if (part != null) {
					resolvedConfig = part.SolutionConfigurations.FirstOrDefault (c => {
						string name, plat;
						ItemConfiguration.ParseConfigurationId (c, out name, out plat);
						return name == currentConfig;
					});
				}
				if (resolvedConfig == null) {
					part = currentTargetPartitions.FirstOrDefault (p => p.ReducedConfigurations.Contains (currentConfig));
					if (part == null)
						part = currentTargetPartitions.FirstOrDefault (p => p.SolutionConfigurations.Contains (currentConfig));
					if (part != null) {
						resolvedTarget = FirstRealExecutionTarget (part.Targets);
						resolvedConfig = part.SolutionConfigurations.FirstOrDefault (c => {
							string name, plat;
							ItemConfiguration.ParseConfigurationId (c, out name, out plat);
							return name == currentConfig;
						});
						if (resolvedConfig == null)
							resolvedConfig = currentConfig;
					} else {
						resolvedTarget = null;
						resolvedConfig = currentConfig;
					}
				}
			}
			if (resolvedTarget == dummyExecutionTarget)
				resolvedTarget = null;
		}
Пример #20
0
        void SelectActiveRuntime()
        {
            ignoreRuntimeChangedCount++;

            try {
                if (ToolbarView.RuntimeModel.Any())
                {
                    ExecutionTarget defaultTarget = null;
                    bool            selected      = false;
                    int             defaultIter   = 0;

                    if (!SelectActiveRuntime(ref selected, ref defaultTarget, ref defaultIter) && !selected)
                    {
                        if (defaultTarget != null)
                        {
                            IdeApp.Workspace.ActiveExecutionTarget = defaultTarget;
                            ToolbarView.ActiveRuntime = ToolbarView.RuntimeModel.ElementAt(defaultIter);
                        }
                        UpdateBuildConfiguration();
                    }

                    if (currentStartupProject == null)
                    {
                        return;
                    }

                    var runtime = (RuntimeModel)ToolbarView.ActiveRuntime;
                    if (runtime != null && runtime.Command == null)
                    {
                        currentStartupProject.UserProperties.SetValue <string> ("PreferredExecutionTarget", runtime.TargetId);
                    }
                }
            } finally {
                ignoreRuntimeChangedCount--;
            }
        }
 public ExecutionContext(IExecutionMode executionMode, IConsoleFactory consoleFactory, ExecutionTarget target = null)
 {
     this.executionHandler = executionMode.ExecutionHandler;
     this.consoleFactory   = consoleFactory;
     this.executionTarget  = target;
 }
Пример #22
0
 public TargetedExecutionHandler(IExecutionHandler handler, ExecutionTarget target)
 {
     Target  = target;
     Handler = handler;
 }
Пример #23
0
 public RuntimeModel(MainToolbarController controller, ExecutionTarget target) : this(controller)
 {
     ExecutionTarget = target;
     Enabled         = !(ExecutionTarget is ExecutionTargetGroup);
     Visible         = true;
 }
Пример #24
0
        void FillRuntimes()
        {
            ignoreRuntimeChangedCount++;
            try {
                ToolbarView.RuntimeModel = Enumerable.Empty <IRuntimeModel> ();
                if (!IdeApp.Workspace.IsOpen || currentSolution == null || !currentSolution.SingleStartup || currentSolution.StartupItem == null)
                {
                    return;
                }

                // Check that the current startup project is enabled for the current configuration
                var solConf = currentSolution.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
                if (solConf == null || !solConf.BuildEnabledForItem(currentSolution.StartupItem))
                {
                    return;
                }

                ExecutionTarget previous = null;
                int             runtimes = 0;

                var list = new List <RuntimeModel> ();
                foreach (var target in configurationMerger.GetTargetsForConfiguration(IdeApp.Workspace.ActiveConfigurationId, true))
                {
                    if (target is ExecutionTargetGroup)
                    {
                        var devices = (ExecutionTargetGroup)target;

                        if (previous != null)
                        {
                            list.Add(new RuntimeModel(this, target: null));
                        }

                        list.Add(new RuntimeModel(this, target));
                        foreach (var device in devices)
                        {
                            if (device is ExecutionTargetGroup)
                            {
                                var versions = (ExecutionTargetGroup)device;

                                if (versions.Count > 1)
                                {
                                    var parent = new RuntimeModel(this, device)
                                    {
                                        IsIndented = true,
                                    };
                                    list.Add(parent);

                                    foreach (var version in versions)
                                    {
                                        list.Add(new RuntimeModel(this, version, parent));
                                        runtimes++;
                                    }
                                }
                                else
                                {
                                    list.Add(new RuntimeModel(this, versions[0])
                                    {
                                        IsIndented = true,
                                    });
                                    runtimes++;
                                }
                            }
                            else
                            {
                                list.Add(new RuntimeModel(this, device)
                                {
                                    IsIndented = true,
                                });
                                runtimes++;
                            }
                        }
                    }
                    else
                    {
                        if (previous is ExecutionTargetGroup)
                        {
                            list.Add(new RuntimeModel(this, target: null));
                        }

                        list.Add(new RuntimeModel(this, target));
                        runtimes++;
                    }

                    previous = target;
                }

                var cmds = IdeApp.CommandService.CreateCommandEntrySet(TargetsMenuPath);
                if (cmds.Count > 0)
                {
                    bool needsSeparator = runtimes > 0;
                    foreach (CommandEntry ce in cmds)
                    {
                        if (ce.CommandId == Command.Separator)
                        {
                            needsSeparator = true;
                            continue;
                        }
                        var cmd = ce.GetCommand(IdeApp.CommandService) as ActionCommand;
                        if (cmd != null)
                        {
                            var ci = IdeApp.CommandService.GetCommandInfo(cmd.Id, new CommandTargetRoute(lastCommandTarget));
                            if (ci.Visible)
                            {
                                if (needsSeparator)
                                {
                                    list.Add(new RuntimeModel(this, target: null));
                                    needsSeparator = false;
                                }
                                list.Add(new RuntimeModel(this, cmd));
                                runtimes++;
                            }
                        }
                    }
                }

                ToolbarView.PlatformSensitivity = runtimes > 1;
                ToolbarView.RuntimeModel        = list;
            } finally {
                ignoreRuntimeChangedCount--;
            }
        }
Пример #25
0
        void FillRuntimes()
        {
            runtimeCombo.Changed -= HandleRuntimeChanged;
            try {
                runtimeStore.Clear();
                if (!IdeApp.Workspace.IsOpen || currentSolution == null || !currentSolution.SingleStartup || currentSolution.StartupItem == null)
                {
                    return;
                }

                // Check that the current startup project is enabled for the current configuration
                var solConf = currentSolution.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
                if (solConf == null || !solConf.BuildEnabledForItem(currentSolution.StartupItem))
                {
                    return;
                }

                ExecutionTarget previous = null;
                int             runtimes = 0;

                foreach (var target in configurationMerger.GetTargetsForConfiguration(IdeApp.Workspace.ActiveConfigurationId, true))
                {
                    if (target is ExecutionTargetGroup)
                    {
                        var devices = (ExecutionTargetGroup)target;

                        if (previous != null)
                        {
                            runtimeStore.AppendValues(null, false);
                        }

                        runtimeStore.AppendValues(target, false);
                        foreach (var device in devices)
                        {
                            if (device is ExecutionTargetGroup)
                            {
                                var versions = (ExecutionTargetGroup)device;

                                if (versions.Count > 1)
                                {
                                    var iter = runtimeStore.AppendValues(device, true);

                                    foreach (var version in versions)
                                    {
                                        runtimeStore.AppendValues(iter, version, false);
                                        runtimes++;
                                    }
                                }
                                else
                                {
                                    runtimeStore.AppendValues(versions[0], true);
                                    runtimes++;
                                }
                            }
                            else
                            {
                                runtimeStore.AppendValues(device, true);
                                runtimes++;
                            }
                        }
                    }
                    else
                    {
                        if (previous is ExecutionTargetGroup)
                        {
                            runtimeStore.AppendValues(null, false);
                        }

                        runtimeStore.AppendValues(target, false);
                        runtimes++;
                    }

                    previous = target;
                }

                runtimeCombo.Sensitive = runtimes > 1;
            } finally {
                runtimeCombo.Changed += HandleRuntimeChanged;
            }
        }
Пример #26
0
 public ExecutionContext(IExecutionMode executionMode, OperationConsoleFactory consoleFactory, ExecutionTarget target)
     : this(executionMode.ExecutionHandler, consoleFactory, target)
 {
 }
Пример #27
0
        void FillRuntimes()
        {
            ignoreRuntimeChangedCount++;
            try {
                runtimeStore.Clear();
                if (!IdeApp.Workspace.IsOpen || currentSolution == null || !currentSolution.SingleStartup || currentSolution.StartupItem == null)
                {
                    return;
                }

                // Check that the current startup project is enabled for the current configuration
                var solConf = currentSolution.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
                if (solConf == null || !solConf.BuildEnabledForItem(currentSolution.StartupItem))
                {
                    return;
                }

                ExecutionTarget previous = null;
                int             runtimes = 0;

                foreach (var target in configurationMerger.GetTargetsForConfiguration(IdeApp.Workspace.ActiveConfigurationId, true))
                {
                    if (target is ExecutionTargetGroup)
                    {
                        var devices = (ExecutionTargetGroup)target;

                        if (previous != null)
                        {
                            runtimeStore.AppendValues(null, false);
                        }

                        runtimeStore.AppendValues(target, false);
                        foreach (var device in devices)
                        {
                            if (device is ExecutionTargetGroup)
                            {
                                var versions = (ExecutionTargetGroup)device;

                                if (versions.Count > 1)
                                {
                                    var iter = runtimeStore.AppendValues(device, true);

                                    foreach (var version in versions)
                                    {
                                        runtimeStore.AppendValues(iter, version, false);
                                        runtimes++;
                                    }
                                }
                                else
                                {
                                    runtimeStore.AppendValues(versions[0], true);
                                    runtimes++;
                                }
                            }
                            else
                            {
                                runtimeStore.AppendValues(device, true);
                                runtimes++;
                            }
                        }
                    }
                    else
                    {
                        if (previous is ExecutionTargetGroup)
                        {
                            runtimeStore.AppendValues(null, false);
                        }

                        runtimeStore.AppendValues(target, false);
                        runtimes++;
                    }

                    previous = target;
                }

                var cmds = IdeApp.CommandService.CreateCommandEntrySet(TargetsMenuPath);
                if (cmds.Count > 0)
                {
                    bool needsSeparator = runtimes > 0;
                    foreach (CommandEntry ce in cmds)
                    {
                        if (ce.CommandId == Command.Separator)
                        {
                            needsSeparator = true;
                            continue;
                        }
                        var cmd = ce.GetCommand(IdeApp.CommandService) as ActionCommand;
                        if (cmd != null)
                        {
                            var ci = IdeApp.CommandService.GetCommandInfo(cmd.Id, new CommandTargetRoute(LastCommandTarget));
                            if (ci.Visible)
                            {
                                if (needsSeparator)
                                {
                                    runtimeStore.AppendValues(null, false);
                                    needsSeparator = false;
                                }
                                runtimeStore.AppendValues(null, false, cmd);
                                runtimes++;
                            }
                        }
                    }
                }

                runtimeCombo.Sensitive = runtimes > 1;
            } finally {
                ignoreRuntimeChangedCount--;
            }
        }
Пример #28
0
 public ExecutionContext(IExecutionHandler executionHandler, IConsoleFactory consoleFactory, ExecutionTarget target)
 {
     this.executionHandler = executionHandler;
     this.consoleFactory   = consoleFactory;
     this.executionTarget  = target;
 }
Пример #29
0
        /// <summary>
        /// Load configuration information for a solution
        /// </summary>
        public void Load(Solution sol)
        {
            currentSolutionConfigurations.Clear();
            currentTargetPartitions.Clear();
            reducedConfigurations.Clear();

            if (sol == null)
            {
                return;
            }

            var project = sol.StartupItem;

            // Create a set of configuration partitions. Each partition will contain configurations
            // which are implicitly selected when selecting an execution target. For example, in
            // an iOS project we would have two partitions:
            //   1) Debug|IPhoneSimulator, Release|IPhoneSimulator
            //      targets: iPhone, iPad
            //   2) Debug|IPhone, Release|IPhone
            //      targets: device

            List <TargetPartition> partitions = new List <TargetPartition> ();

            if (project != null)
            {
                foreach (var conf in project.Configurations)
                {
                    var targets = project.GetExecutionTargets(conf.Selector);
                    if (!targets.Any())
                    {
                        targets = new ExecutionTarget[] { dummyExecutionTarget };
                    }
                    var parts = partitions.Where(p => targets.Any(t => p.Targets.Contains(t))).ToArray();
                    if (parts.Length == 0)
                    {
                        // Create a new partition for this configuration
                        var p = new TargetPartition();
                        p.Configurations.Add(conf.Id);
                        p.Targets.UnionWith(targets);
                        partitions.Add(p);
                    }
                    else if (parts.Length == 1)
                    {
                        // Register the configuration into an existing partition
                        parts[0].Configurations.Add(conf.Id);
                        parts[0].Targets.UnionWith(targets);
                    }
                    else
                    {
                        // The partitions have to be merged into a single one
                        for (int n = 1; n < parts.Length; n++)
                        {
                            parts[0].Configurations.UnionWith(parts[n].Configurations);
                            parts[0].Targets.UnionWith(parts[n].Targets);
                            partitions.Remove(parts[n]);
                        }
                    }
                }

                // The startup project configuration partitions are used to create solution configuration partitions

                foreach (var solConf in sol.Configurations)
                {
                    var pconf = solConf.GetEntryForItem(project);
                    if (pconf != null && pconf.Build)
                    {
                        var part = partitions.FirstOrDefault(p => p.Configurations.Contains(pconf.ItemConfiguration));
                        if (part != null)
                        {
                            part.SolutionConfigurations.Add(solConf.Id);
                            continue;
                        }
                    }
                    // The solution configuration is not bound to the startup project
                    // Add it to all partitions so that it can still take part of
                    // the solution configuration simplification process
                    foreach (var p in partitions)
                    {
                        p.SolutionConfigurations.Add(solConf.Id);
                    }
                }
            }

            if (partitions.Count == 0)
            {
                // There is no startup project, just use all solution configurations in this case
                var p = new TargetPartition();
                p.SolutionConfigurations.AddRange(sol.GetConfigurations());
                partitions.Add(p);
            }

            // There can be several configurations with the same prefix and different platform but which build the same projects.
            // If all configurations with the same prefix are identical, all of them can be reduced into a single configuration
            // with no platform name. This loop detects such configurations

            var notReducibleConfigurations = new HashSet <string> ();

            foreach (var p in partitions)
            {
                var groupedConfigs = p.SolutionConfigurations.GroupBy(sc => {
                    string name, plat;
                    ItemConfiguration.ParseConfigurationId(sc, out name, out plat);
                    return(name);
                }).ToArray();
                foreach (var confGroup in groupedConfigs)
                {
                    var configs  = confGroup.ToArray();
                    var baseConf = sol.Configurations[configs[0]];
                    if (configs.Skip(1).All(c => ConfigurationEquals(sol, baseConf, sol.Configurations[c])))
                    {
                        p.ReducedConfigurations.Add(confGroup.Key);
                    }
                    else
                    {
                        notReducibleConfigurations.Add(confGroup.Key);
                    }
                }
            }

            // To really be able to use reduced configuration names, all partitions must have that reduced configuration
            // Find the configurations that have been reduced in all partitions

            reducedConfigurations = new HashSet <string> (partitions.SelectMany(p => p.ReducedConfigurations));
            reducedConfigurations.ExceptWith(notReducibleConfigurations);

            // Final merge of configurations

            var result = new HashSet <string> ();

            foreach (var p in partitions)
            {
                result.UnionWith(p.SolutionConfigurations);
            }

            // Replace reduced configurations

            foreach (var reducedConf in reducedConfigurations)
            {
                result.RemoveWhere(c => {
                    string name, plat;
                    ItemConfiguration.ParseConfigurationId(c, out name, out plat);
                    return(name == reducedConf);
                });
                result.Add(reducedConf);
            }
            currentTargetPartitions = partitions;
            currentSolutionConfigurations.AddRange(result);
            currentSolutionConfigurations.Sort();
        }
Пример #30
0
 public RuntimeModel(MainToolbarController controller, ExecutionTarget target) : this(controller)
 {
     ExecutionTarget = target;
 }