コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }