예제 #1
0
        protected override void OnExec()
        {
            IAssetReferenceService referenceservice = ServiceProvider.GetService <IAssetReferenceService>(true);
            IAssetReference        reference        = referenceservice.GetReferenceFor(recipe.Name, GetTarget());

            if (reference == null)
            {
                throw new ArgumentNullException("reference");
            }
            reference.Execute();
        }
예제 #2
0
        /// <summary>
        /// Executes the reference.
        /// </summary>
        /// <param name="reference">The IAssetReference that will be execute.</param>
        private void ExecuteReference(IAssetReference reference)
        {
            if (reference == null)
            {
                return;
            }

            try
            {
                IHostService host = (IHostService)ServiceHelper.GetService(this, typeof(IHostService));

                bool execute = false;
                if (reference is IBoundAssetReference)
                {
                    IBoundAssetReference boundReferece = reference as IBoundAssetReference;
                    if (boundReferece.Target == null)
                    {
                        // this is a stale bound reference: tell the user and refresh the list of available guidance
                        MessageBox.Show(Properties.Resources.Navigator_StaleReference, Properties.Resources.Navigator_StaleReferenceTitle);
                        // invalidate the cache to remove stale references
                        this.UpdateAvailableGuidance(true);
                        return;
                    }
                    execute = host.SelectTarget(((IBoundAssetReference)reference).Target);
                }
                else if (reference is IUnboundAssetReference)
                {
                    execute = host.SelectTarget(this, (IUnboundAssetReference)reference);
                }

                if (execute)
                {
                    selectedGuidancePackage.TurnOnOutput();
                    reference.Execute();
                }
            }
            catch (Exception ex)
            {
                ErrorHelper.Show((IUIService)GetService(typeof(IUIService)), ex);
            }
            finally
            {
                if (selectedGuidancePackage != null)
                {
                    selectedGuidancePackage.TurnOffOutput();
                }
            }
        }
예제 #3
0
        private void OnExecuteRecipe(object sender, System.EventArgs e)
        {
            GuidancePackage Package = null;

            try
            {
                if (lstRecipes.SelectedItems.Count == 0)
                {
                    MessageBox.Show(this, Configuration.Resources.PackageManager_MustSelectRecipe,
                                    this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                IHostService    host      = (IHostService)ServiceHelper.GetService(this, typeof(IHostService));
                IAssetReference reference = ((ReferenceInfo)lstRecipes.SelectedItems[0].Tag).Reference;
                bool            execute   = false;
                if (reference is IBoundAssetReference)
                {
                    execute = host.SelectTarget(((IBoundAssetReference)reference).Target);
                }
                else if (reference is IUnboundAssetReference)
                {
                    execute = host.SelectTarget(this, (IUnboundAssetReference)reference);
                }

                if (execute)
                {
                    Package = (GuidancePackage)ServiceHelper.GetService(reference, typeof(IExecutionService));
                    Package.TurnOnOutput();
                    reference.Execute();
                    LoadReferences();
                }
            }
            catch (Exception ex)
            {
                ErrorHelper.Show((IUIService)GetService(typeof(IUIService)), ex);
            }
            finally
            {
                if (Package != null)
                {
                    Package.TurnOffOutput();
                }
            }
        }