Esempio n. 1
0
        internal void CompleteInitializationOfUnfoldedExtension(string extensionId,
                                                                IGuidanceExtension extensionInstance)
        {
            //
            // First, find the instance and fixup the workflow
            //
            foreach (var x in instantiatedGuidanceExtensions.ToList())
            {
                if (x.Item1.InstanceName == extensionInstance.InstanceName)
                {
                    GuidanceExtension fx = x.Item1 as GuidanceExtension;
                    fx.GuidanceWorkflow = extensionInstance.GuidanceWorkflow;
                    break;
                }
            }

            //
            // Then add this FX to the solution (if desired)
            //
            if (extensionInstance.PersistInstanceInSolution)
            {
                var registration = this.InstalledGuidanceExtensions.First(f => f.ExtensionId == extensionId);
                solutionState.AddExtension(extensionId, extensionInstance.InstanceName, registration.ExtensionManifest.Header.Version);
            }

            //
            // Update the InstantiatedExtensions list which will get the workflow into the
            // Workflow Explorer
            InstantiatedExtensionsChanged(this, EventArgs.Empty);
            RaisePropertyChanged(x => x.InstantiatedGuidanceExtensions);
        }
Esempio n. 2
0
 private static string GetDescription(IGuidanceManager guidanceManager, IGuidanceExtension extension)
 {
     return(guidanceManager.InstalledGuidanceExtensions
            .Where(reg => reg.ExtensionId.Equals(extension.ExtensionId, StringComparison.OrdinalIgnoreCase))
            .Select(reg => reg.ExtensionManifest.Header.Description)
            .FirstOrDefault());
 }
Esempio n. 3
0
        /// <summary>
        /// Determines whether the link can be executed.
        /// </summary>
        public override bool CanExecute(IGuidanceExtension extension)
        {
            Guard.NotNull(() => extension, extension);

            return(extension.GuidanceManager.InstalledGuidanceExtensions
                   .Any(f => f.ExtensionId.Equals(HandsOnLabsToolkitInfo.Identifier, StringComparison.OrdinalIgnoreCase)));
        }
Esempio n. 4
0
        /// <summary>
        /// Determines whether the link can be executed.
        /// </summary>
        public override bool CanExecute(IGuidanceExtension extension)
        {
            Guard.NotNull(() => extension, extension);

            return extension.GuidanceManager.InstalledGuidanceExtensions
                .Any(f => f.ExtensionId.Equals(HandsOnLabsToolkitInfo.Identifier, StringComparison.OrdinalIgnoreCase));
        }
Esempio n. 5
0
        /// <summary>
        /// Refreshes the guidance workflow
        /// </summary>
        /// <param name="extension"></param>
        public void RefreshWorkflow(IGuidanceExtension extension)
        {
            var realExt = extension as GuidanceExtension;

            //
            // First, remove our guidance extension from the instantiated list
            // and raise the event (which will cause it to be removed from the UX)
            //
            extension.Finish();
            instantiatedGuidanceExtensions.RemoveAll(state => state.Item1.ExtensionId == extension.ExtensionId && state.Item1.InstanceName == extension.InstanceName);
            InstantiatedExtensionsChanged(this, EventArgs.Empty);
            RaisePropertyChanged(x => x.InstantiatedGuidanceExtensions);

            realExt.GuidanceWorkflow = realExt.CreateWorkflow();
            if (realExt.GuidanceWorkflow != null)
            {
                realExt.GuidanceWorkflow.OwningExtension = extension;
            }

            //
            // Now put it back and make it active
            //
            instantiatedGuidanceExtensions.Add(new Tuple <IGuidanceExtension, INuPatternCompositionService>(extension, realExt.GuidanceComposition));
            InstantiatedExtensionsChanged(this, EventArgs.Empty);
            RaisePropertyChanged(x => x.InstantiatedGuidanceExtensions);
            this.ActiveGuidanceExtension = extension;
        }
Esempio n. 6
0
        /// <summary>
        /// Executes the launch point.
        /// </summary>
        public virtual void Execute(IGuidanceExtension extension)
        {
            if (!this.CanExecute(extension))
            {
                throw new InvalidOperationException(string.Format(
                                                        CultureInfo.CurrentCulture,
                                                        Resources.VsLaunchPoint_ErrorCommandCannotExecute,
                                                        this.BindingName));
            }

            var commandBindingForEval = extension.Commands.FindByName(this.BindingName);

            if (commandBindingForEval != null)
            {
                commandBindingForEval.Evaluate();
            }

            var tracer = Tracer.Get(extension.GetType());

            using (tracer.StartActivity(Resources.VsLaunchPoint_TraceExecute, BindingName))
            {
                var commandBinding = extension.Commands.FindByName(this.BindingName);
                commandBinding.Value.Execute();
            }
        }
 private static string GetDescription(IGuidanceManager guidanceManager, IGuidanceExtension extension)
 {
     return guidanceManager.InstalledGuidanceExtensions
         .Where(reg => reg.ExtensionId.Equals(extension.ExtensionId, StringComparison.OrdinalIgnoreCase))
         .Select(reg => reg.ExtensionManifest.Header.Description)
         .FirstOrDefault();
 }
 internal GuidanceActionViewModel(IGuidanceExtension feature, IGuidanceAction model, ImageSource icon)
     : base(model, icon)
 {
     this.Node.HasStateOverrideChanged += (s, e) => this.OnPropertyChanged(() => this.HasStateOverride);
     this.RequiresUserAcceptance = model.Postconditions.OfType<UserAcceptanceBinding>().Any();
     this.Conditions = GetConditions(model);
     this.Model.StateChanged += (s, e) => this.RefreshDetails();
     this.feature = feature;
 }
Esempio n. 9
0
 internal GuidanceActionViewModel(IGuidanceExtension feature, IGuidanceAction model, ImageSource icon)
     : base(model, icon)
 {
     this.Node.HasStateOverrideChanged += (s, e) => this.OnPropertyChanged(() => this.HasStateOverride);
     this.RequiresUserAcceptance        = model.Postconditions.OfType <UserAcceptanceBinding>().Any();
     this.Conditions          = GetConditions(model);
     this.Model.StateChanged += (s, e) => this.RefreshDetails();
     this.feature             = feature;
 }
        private IGuidanceAction FindNodeBasedOnContentLink(IGuidanceExtension feature, string link)
        {
            IGuidanceAction focusedAction = feature.GuidanceWorkflow.Successors
                                            .Traverse <INode>(s => s.Successors)
                                            .OfType <IGuidanceAction>()
                                            .FirstOrDefault(a => (a.Link == null ? @"~~~" : a.Link.ToLower()) == link.ToLower());

            return(focusedAction);
        }
        /// <summary>
        /// Binds the state of the guidance workflow to Blackboard data,
        /// and starts tracking changes in the workflow to update the underlying
        /// storage in the Blackboard
        /// </summary>
        public BlackboardWorkflowBinder(IGuidanceExtension feature, IGuidanceWorkflow guidanceWorkflow)
        {
            this.tracer           = Tracer.Get <BlackboardWorkflowBinder>();
            this.guidanceWorkflow = guidanceWorkflow;

            this.feature = feature;

            //
            // Note: For BlackboardWorkflowBinder we don't set the WF state here because we have to wait
            // until the OnInitialize in Feature.cs initializes the Blackboard.
            //
            this.TrackChanges();
        }
        public virtual bool CanExecute(IGuidanceExtension extension)
        {
            if (extension == null)
            {
                extension = this.GuidanceInstanceLocator.LocateInstance();
            }

            if (this.GuidanceInstantiation != GuidanceInstantiation.None)
            {
                return true;
            }

            return this.QueryStatusStrategy.QueryStatus(extension).Enabled;
        }
Esempio n. 13
0
        public virtual bool CanExecute(IGuidanceExtension extension)
        {
            if (extension == null)
            {
                extension = this.GuidanceInstanceLocator.LocateInstance();
            }

            if (this.GuidanceInstantiation != GuidanceInstantiation.None)
            {
                return(true);
            }

            return(this.QueryStatusStrategy.QueryStatus(extension).Enabled);
        }
        /// <summary>
        /// Binds the state of the guidance workflow to Blackboard data, 
        /// and starts tracking changes in the workflow to update the underlying 
        /// storage in the Blackboard
        /// </summary>
        public BlackboardWorkflowBinder(IGuidanceExtension feature, IGuidanceWorkflow guidanceWorkflow)
        {

            this.tracer = Tracer.Get<BlackboardWorkflowBinder>();
            this.guidanceWorkflow = guidanceWorkflow;

            this.feature = feature;

            //
            // Note: For BlackboardWorkflowBinder we don't set the WF state here because we have to wait
            // until the OnInitialize in Feature.cs initializes the Blackboard.
            //
            this.TrackChanges();
        }
Esempio n. 15
0
            public void Initialize()
            {
                ElementSchema element = null;

                this.store = new Store(VsIdeTestHostContext.ServiceProvider,
                    new[] { typeof(CoreDesignSurfaceDomainModel), typeof(PatternModelDomainModel), typeof(LibraryDomainModel) });

                this.store.TransactionManager.DoWithinTransaction(() =>
                {
                    this.store.ElementFactory.CreateElement<PatternModelSchema>();
                    element = this.store.ElementFactory.CreateElement<ElementSchema>();
                });

                this.guidanceExtension = element.GetExtensions<IGuidanceExtension>().FirstOrDefault();
                this.container = element as IPatternElementSchema;
            }
Esempio n. 16
0
            public void Initialize()
            {
                ElementSchema element = null;

                this.store = new Store(VsIdeTestHostContext.ServiceProvider,
                                       new[] { typeof(CoreDesignSurfaceDomainModel), typeof(PatternModelDomainModel), typeof(LibraryDomainModel) });

                this.store.TransactionManager.DoWithinTransaction(() =>
                {
                    this.store.ElementFactory.CreateElement <PatternModelSchema>();
                    element = this.store.ElementFactory.CreateElement <ElementSchema>();
                });

                this.guidanceExtension = element.GetExtensions <IGuidanceExtension>().FirstOrDefault();
                this.container         = element as IPatternElementSchema;
            }
Esempio n. 17
0
        /// <summary>
        /// Determines whether the launch point can execute.
        /// </summary>
        public virtual bool CanExecute(IGuidanceExtension extension)
        {
            if (extension != null)
            {
                var commandBinding = extension.Commands.FindByName(this.BindingName);
                if (commandBinding != null)
                {
                    return(true);
                    // used to be return commandBinding.Evaluate();
                    // but this cannot be done because evaluating a commandBinding, evaluates all its
                    // arguments as well which breaks the concept of a value provider running a wizard
                    // Evaluation is now deferred to the actual call to Execute
                }
            }

            return(false);
        }
Esempio n. 18
0
        /// <summary>
        /// Determines whether the launch point can execute.
        /// </summary>
        public virtual bool CanExecute(IGuidanceExtension extension)
        {
            if (extension != null)
            {
                var commandBinding = extension.Commands.FindByName(this.BindingName);
                if (commandBinding != null)
                {
                    return true;
                    // used to be return commandBinding.Evaluate();
                    // but this cannot be done because evaluating a commandBinding, evaluates all its
                    // arguments as well which breaks the concept of a value provider running a wizard
                    // Evaluation is now deferred to the actual call to Execute
                }
            }

            return false;
        }
Esempio n. 19
0
        /// <summary>
        /// Whether the binding can be executed.
        /// </summary>
        /// <param name="extension"></param>
        /// <returns></returns>
        public virtual bool CanExecute(IGuidanceExtension extension)
        {
            if (extension != null && this.QueryStatusStrategy.QueryStatus(extension).Enabled)
            {
                // Verify the action is enabled.
                var activeWorkflow = extension.GuidanceWorkflow != null ? extension.GuidanceWorkflow : GuidanceManager.ActiveGuidanceExtension.GuidanceWorkflow;
                if (activeWorkflow != null)
                {
                    var node = activeWorkflow.FocusedAction as INode;
                    if (node.State == NodeState.Enabled)
                        return true;
                }
            }

            NotifyUser();

            return false;
        }
Esempio n. 20
0
        /// <summary>
        /// Whether the binding can be executed.
        /// </summary>
        /// <param name="extension"></param>
        /// <returns></returns>
        public virtual bool CanExecute(IGuidanceExtension extension)
        {
            if (extension != null && this.QueryStatusStrategy.QueryStatus(extension).Enabled)
            {
                // Verify the action is enabled.
                var activeWorkflow = extension.GuidanceWorkflow != null ? extension.GuidanceWorkflow : GuidanceManager.ActiveGuidanceExtension.GuidanceWorkflow;
                if (activeWorkflow != null)
                {
                    var node = activeWorkflow.FocusedAction as INode;
                    if (node.State == NodeState.Enabled)
                    {
                        return(true);
                    }
                }
            }

            NotifyUser();

            return(false);
        }
        public static void EvaluateGraph(IGuidanceExtension extension)
        {
            Guard.NotNull(() => extension, extension);

            currentExtensionInstance = extension;

            var workflow = extension.GuidanceWorkflow;

            if (workflow != null)
            {
                TraceStateChanges = GuidanceManagerSettings.VerboseTracing = workflow.Successors.ToArray <INode>()[0].Name.StartsWith(DebugToken);
                GuidanceManagerSettings.VerboseBindingTracing = workflow.Successors.ToArray <INode>()[0].Name.Equals(DebugWithBindingsToken, StringComparison.OrdinalIgnoreCase);

                EvaluateNode(workflow);

                IList <IConditionalNode> nodes = NodesToEvaluate(workflow);
                foreach (var conditionalNode in nodes)
                {
                    EvaluateNode(conditionalNode);
                }
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Executes the binding
        /// </summary>
        /// <param name="extension"></param>
        public virtual void Execute(IGuidanceExtension extension)
        {
            if (!this.CanExecute(extension))
            {
                throw new InvalidOperationException(string.Format(
                    CultureInfo.CurrentCulture,
                    Resources.LinkLaunchPoint_ErrorCommandCannotExecute,
                    this.BindingName));
            }

            var tracer = Tracer.Get<LinkLaunchPoint>();

            using (tracer.StartActivity(Resources.LinkLaunchPoint_TraceExecute, BindingName))
            {
                var commandBinding = extension.Commands.FindByName(this.BindingName);
                if (commandBinding != null)
                {
                    commandBinding.Evaluate();
                    commandBinding.Value.Execute();
                }
            }
        }
Esempio n. 23
0
        private INuPatternCompositionService CreateCompositionService(IGuidanceExtension extension, string extensionId)
        {
            var extensionContainer = new CompositionContainer(extensionsGlobalContainer);

            // Expose IGuidanceExtension to the container
            extensionContainer.ComposeExportedValue(extension);
            extensionContainer.ComposeExportedValue(InstalledGuidanceExtensions.First(r => r.ExtensionId == extensionId));

            extensionContainer.ComposeExportedValue <ExportProvider>(extensionContainer);

            var compositionService = new NuPatternCompositionService(extensionContainer);

            // Expose IGuidanceExtensionCompositionService to the container
            extensionContainer.ComposeExportedValue <INuPatternCompositionService>(compositionService);

            // Satisfy imports at this level, so that the right guidance extension-level stuff is injected instead
            // (i.e. the guidance extension might have specified an import of the IGudianceExtensionCompositionService and
            // would have gotten the global one.
            compositionService.SatisfyImportsOnce(extension);

            return(compositionService);
        }
        public static string UserAcceptedKey(IGuidanceExtension feature, object node)
        {
            var guidanceNode = node as IConditionalNode;

            return (feature.InstanceName + @"." + guidanceNode.Name + @".UserAccepted");
        }
Esempio n. 25
0
        internal void CompleteInitializationOfUnfoldedExtension(string extensionId,
            IGuidanceExtension extensionInstance)
        {
            //
            // First, find the instance and fixup the workflow
            //
            foreach (var x in instantiatedGuidanceExtensions.ToList())
            {
                if (x.Item1.InstanceName == extensionInstance.InstanceName)
                {
                    GuidanceExtension fx = x.Item1 as GuidanceExtension;
                    fx.GuidanceWorkflow = extensionInstance.GuidanceWorkflow;
                    break;
                }
            }

            //
            // Then add this FX to the solution (if desired)
            //
            if (extensionInstance.PersistInstanceInSolution)
            {
                var registration = this.InstalledGuidanceExtensions.First(f => f.ExtensionId == extensionId);
                solutionState.AddExtension(extensionId, extensionInstance.InstanceName, registration.ExtensionManifest.Header.Version);
            }

            //
            // Update the InstantiatedExtensions list which will get the workflow into the
            // Workflow Explorer
            InstantiatedExtensionsChanged(this, EventArgs.Empty);
            RaisePropertyChanged(x => x.InstantiatedGuidanceExtensions);
        }
        public static string UserAcceptedKey(IGuidanceExtension feature, object node)
        {
            var guidanceNode = node as IConditionalNode;

            return(feature.InstanceName + @"." + guidanceNode.Name + @".UserAccepted");
        }
        public static string StateOverrideKey(IGuidanceExtension feature, object node)
        {
            var guidanceNode = node as IConditionalNode;

            return(feature.InstanceName + @"." + guidanceNode.Name + @".StateOverride");
        }
        public static void ActivateGuidanceInstance(this IGuidanceManager guidanceManager, IServiceProvider provider, IGuidanceExtension instance)
        {
            Guard.NotNull(() => guidanceManager, guidanceManager);
            Guard.NotNull(() => provider, provider);
            Guard.NotNull(() => instance, instance);

            if (provider != null)
            {
                guidanceManager.ShowGuidanceWindows(provider);
            }

            tracer.Info(Resources.GuidanceManagerExtensions_TraceActivation, instance.InstanceName);

            // Activate guidance extension in Guidance Explorer
            guidanceManager.ActiveGuidanceExtension = instance;
        }
        public QueryStatus QueryStatus(IGuidanceExtension feature)
        {
            var status = new QueryStatus {
                Visible = false, Enabled = false
            };

            if (feature == null)
            {
                return(status);
            }


            //
            // First, let's check to see if our feature has a workflow
            //
            if (feature.GuidanceWorkflow != null)
            {
                var associatedActions = feature.GuidanceWorkflow.Successors
                                        .Traverse(node => node.Successors)
                                        .OfType <IGuidanceAction>()
                                        .Where(activity => activity.LaunchPoints.Contains(launchPointName))
                                        .ToArray();

                // If there are no associated actions, it's visible + enabled.
                if (!associatedActions.Any())
                {
                    status.Enabled = status.Visible = true;
                }
                else
                {
                    var hasAvailableActions = associatedActions.Any(action => action.State == NodeState.Enabled);
                    status.Visible = status.Enabled = hasAvailableActions;
                }
            }
            else
            {
                //
                // If we don't have a workflow, look at the "active" workflow
                //
                if (feature.GuidanceManager != null &&
                    feature.GuidanceManager.ActiveGuidanceExtension != null &&
                    feature.GuidanceManager.ActiveGuidanceExtension.GuidanceWorkflow != null)
                {
                    status.Enabled = status.Visible = true;
                    var associatedActions = feature.GuidanceManager.ActiveGuidanceExtension.GuidanceWorkflow.Successors
                                            .Traverse(node => node.Successors)
                                            .OfType <IGuidanceAction>()
                                            .Where(activity => activity.LaunchPoints.Contains(launchPointName))
                                            .ToArray();

                    // If there are no associated actions, it's visible + enabled.
                    if (!associatedActions.Any())
                    {
                        status.Enabled = status.Visible = true;
                    }
                    else
                    {
                        var hasAvailableActions = associatedActions.Any(action => action.State == NodeState.Enabled);
                        status.Visible = status.Enabled = hasAvailableActions;
                    }
                }
            }
            return(status);
        }
Esempio n. 30
0
 /// <summary>
 /// Removes the given guidance workflow
 /// </summary>
 /// <param name="extension"></param>
 public void RemoveWorkflow(IGuidanceExtension extension)
 {
     extension.Finish();
     instantiatedGuidanceExtensions.RemoveAll(state => state.Item1.ExtensionId == extension.ExtensionId && state.Item1.InstanceName == extension.InstanceName);
 }
Esempio n. 31
0
        private INuPatternCompositionService CreateCompositionService(IGuidanceExtension extension, string extensionId)
        {
            var extensionContainer = new CompositionContainer(extensionsGlobalContainer);

            // Expose IGuidanceExtension to the container
            extensionContainer.ComposeExportedValue(extension);
            extensionContainer.ComposeExportedValue(InstalledGuidanceExtensions.First(r => r.ExtensionId == extensionId));

            extensionContainer.ComposeExportedValue<ExportProvider>(extensionContainer);

            var compositionService = new NuPatternCompositionService(extensionContainer);
            // Expose IGuidanceExtensionCompositionService to the container
            extensionContainer.ComposeExportedValue<INuPatternCompositionService>(compositionService);

            // Satisfy imports at this level, so that the right guidance extension-level stuff is injected instead 
            // (i.e. the guidance extension might have specified an import of the IGudianceExtensionCompositionService and 
            // would have gotten the global one.
            compositionService.SatisfyImportsOnce(extension);

            return compositionService;
        }
Esempio n. 32
0
        /// <summary>
        /// Refreshes the guidance workflow
        /// </summary>
        /// <param name="extension"></param>
        public void RefreshWorkflow(IGuidanceExtension extension)
        {
            var realExt = extension as GuidanceExtension;

            //
            // First, remove our guidance extension from the instantiated list
            // and raise the event (which will cause it to be removed from the UX)
            //
            extension.Finish();
            instantiatedGuidanceExtensions.RemoveAll(state => state.Item1.ExtensionId == extension.ExtensionId && state.Item1.InstanceName == extension.InstanceName);
            InstantiatedExtensionsChanged(this, EventArgs.Empty);
            RaisePropertyChanged(x => x.InstantiatedGuidanceExtensions);

            realExt.GuidanceWorkflow = realExt.CreateWorkflow();
            if (realExt.GuidanceWorkflow != null)
                realExt.GuidanceWorkflow.OwningExtension = extension;

            //
            // Now put it back and make it active
            //
            instantiatedGuidanceExtensions.Add(new Tuple<IGuidanceExtension, INuPatternCompositionService>(extension, realExt.GuidanceComposition));
            InstantiatedExtensionsChanged(this, EventArgs.Empty);
            RaisePropertyChanged(x => x.InstantiatedGuidanceExtensions);
            this.ActiveGuidanceExtension = extension;
        }
Esempio n. 33
0
 /// <summary>
 /// Removes the given guidance workflow
 /// </summary>
 /// <param name="extension"></param>
 public void RemoveWorkflow(IGuidanceExtension extension)
 {
     extension.Finish();
     instantiatedGuidanceExtensions.RemoveAll(state => state.Item1.ExtensionId == extension.ExtensionId && state.Item1.InstanceName == extension.InstanceName);
 }
 public virtual void Execute(IGuidanceExtension extension)
 {
 }
        public static string StateOverrideKey(IGuidanceExtension feature, object node)
        {
            var guidanceNode = node as IConditionalNode;

            return (feature.InstanceName + @"." + guidanceNode.Name + @".StateOverride");
        }
Esempio n. 36
0
        public static void ActivateGuidanceInstance(this IGuidanceManager guidanceManager, IServiceProvider provider, IGuidanceExtension instance)
        {
            Guard.NotNull(() => guidanceManager, guidanceManager);
            Guard.NotNull(() => provider, provider);
            Guard.NotNull(() => instance, instance);

            if (provider != null)
            {
                guidanceManager.ShowGuidanceWindows(provider);
            }

            tracer.Info(Resources.GuidanceManagerExtensions_TraceActivation, instance.InstanceName);

            // Activate guidance extension in Guidance Explorer
            guidanceManager.ActiveGuidanceExtension = instance;
        }
Esempio n. 37
0
 /// <summary>
 /// Determines if the link can be executed. Overrides the default implementation that checks
 /// if the current workflow node is in the enabled state.
 /// </summary>
 public override bool CanExecute(IGuidanceExtension feature)
 {
     return true;
 }
Esempio n. 38
0
 public virtual void Execute(IGuidanceExtension extension)
 {
 }
Esempio n. 39
0
        public DefaultWorkflowViewModelBuilder(IGuidanceExtension extension)
        {
            Guard.NotNull(() => extension, extension);

            this.extension = extension;
        }
 /// <summary>
 /// Determines whether the link can be executed.
 /// </summary>
 public override bool CanExecute(IGuidanceExtension extension)
 {
     return(true);
 }
        public QueryStatus QueryStatus(IGuidanceExtension feature)
        {
            var status = new QueryStatus { Visible = false, Enabled = false };
            if (feature == null)
            {
                return status;
            }


            //
            // First, let's check to see if our feature has a workflow
            //
            if (feature.GuidanceWorkflow != null)
            {
                var associatedActions = feature.GuidanceWorkflow.Successors
                    .Traverse(node => node.Successors)
                    .OfType<IGuidanceAction>()
                    .Where(activity => activity.LaunchPoints.Contains(launchPointName))
                    .ToArray();

                // If there are no associated actions, it's visible + enabled.
                if (!associatedActions.Any())
                {
                    status.Enabled = status.Visible = true;
                }
                else
                {
                    var hasAvailableActions = associatedActions.Any(action => action.State == NodeState.Enabled);
                    status.Visible = status.Enabled = hasAvailableActions;
                }
            }
            else
            {
                //
                // If we don't have a workflow, look at the "active" workflow
                //
                if (feature.GuidanceManager != null &&
                    feature.GuidanceManager.ActiveGuidanceExtension != null &&
                    feature.GuidanceManager.ActiveGuidanceExtension.GuidanceWorkflow != null)
                {
                    status.Enabled = status.Visible = true;
                    var associatedActions = feature.GuidanceManager.ActiveGuidanceExtension.GuidanceWorkflow.Successors
                        .Traverse(node => node.Successors)
                        .OfType<IGuidanceAction>()
                        .Where(activity => activity.LaunchPoints.Contains(launchPointName))
                        .ToArray();

                    // If there are no associated actions, it's visible + enabled.
                    if (!associatedActions.Any())
                    {
                        status.Enabled = status.Visible = true;
                    }
                    else
                    {
                        var hasAvailableActions = associatedActions.Any(action => action.State == NodeState.Enabled);
                        status.Visible = status.Enabled = hasAvailableActions;
                    }
                }
            }
            return status;
        }