示例#1
0
        protected GuidanceLinkBase(IGuidanceManager guidanceManager, string bindingName)
            : base(guidanceManager)
        {
            Guard.NotNull(() => bindingName, bindingName);

            this.bindingName = bindingName;
        }
        public GuidanceConditionsEvaluator(IGuidanceManager guidanceManager)
        {
            Guard.NotNull(() => guidanceManager, guidanceManager);

            this.guidanceManager = guidanceManager;
            Current = this;
        }
示例#3
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());
 }
示例#4
0
        /// <summary>
        /// Gets whether the given guidance extension is installed in the system.
        /// </summary>
        public static bool IsInstalled(this IGuidanceManager manager, string extensionId)
        {
            Guard.NotNull(() => manager, manager);
            Guard.NotNullOrEmpty(() => extensionId, extensionId);

            return(manager.FindRegistration(extensionId) != null);
        }
示例#5
0
        public static void ActivateSharedGuidanceWorkflow(this IGuidanceManager guidanceManager, IServiceProvider provider, string extensionId)
        {
            Guard.NotNull(() => guidanceManager, guidanceManager);
            Guard.NotNull(() => provider, provider);
            Guard.NotNullOrEmpty(() => extensionId, extensionId);

            var registration = guidanceManager.InstalledGuidanceExtensions.First(e => e.ExtensionId == extensionId);

            if (registration == null)
            {
                tracer.Error(Resources.GuidanceManagerExtensions_ErrorNoRegistration, extensionId);
                return;
            }
            else
            {
                // Ensure at least one instance exists
                var instance = guidanceManager.InstantiatedGuidanceExtensions.FirstOrDefault(e => e.ExtensionId == extensionId);
                if (instance == null)
                {
                    // Create the first instance of the guidance
                    tracer.ShieldUI(() =>
                    {
                        instance = guidanceManager.Instantiate(extensionId, registration.DefaultName);
                    }, Resources.GuidanceManagerExtensions_ErrorGuidanceInstantiationFailed, registration.DefaultName, extensionId);
                }

                // Activate the instance
                if (instance != null)
                {
                    guidanceManager.ActivateGuidanceInstance(provider, instance);
                }
            }
        }
示例#6
0
        /// <summary>
        /// Gets whether the given guidance extension has been instantiated in the solution.
        /// </summary>
        public static bool IsInstantiated(this IGuidanceManager manager, string extensionId)
        {
            Guard.NotNull(() => manager, manager);
            Guard.NotNullOrEmpty(() => extensionId, extensionId);

            return(manager.InstantiatedGuidanceExtensions.Any(ge => ge.ExtensionId.Equals(extensionId, StringComparison.OrdinalIgnoreCase)));
        }
示例#7
0
        protected GuidanceLinkBase(IGuidanceManager guidanceManager, string bindingName)
            : base(guidanceManager)
        {
            Guard.NotNull(() => bindingName, bindingName);

            this.bindingName = bindingName;
        }
示例#8
0
        /// <summary>
        /// Gets the registration with given extension
        /// </summary>
        public static IGuidanceExtensionRegistration FindRegistration(this IGuidanceManager manager, string extensionId)
        {
            Guard.NotNull(() => manager, manager);
            Guard.NotNullOrEmpty(() => extensionId, extensionId);

            return(manager.InstalledGuidanceExtensions.FirstOrDefault(reg => reg.ExtensionId.Equals(extensionId, StringComparison.OrdinalIgnoreCase)));
        }
 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();
 }
示例#10
0
        /// <summary>
        /// Instantiates the guidance extension in a solution.
        /// </summary>
        /// <param name="registration">The guidance extension registration information, which includes its identifier and manifest information..</param>
        /// <param name="instanceName">Name of the instance.</param>
        /// <param name="guidanceManager">An instance of the <see cref="IGuidanceManager"/></param>
        /// <remarks>
        /// This method is called when a feature is first instantiated in a solution.
        /// </remarks>
        public void Instantiate(IGuidanceExtensionRegistration registration, string instanceName, IGuidanceManager guidanceManager)
        {
            using (new GuidanceExtensionInstantiationScope())
            {
                this.ExtensionId     = registration.ExtensionId;
                this.guidanceManager = guidanceManager;
                this.InstanceName    = instanceName;
                this.Registration    = registration;
                this.Trace           = Tracer.Get(this.GetType());

                this.OnInstantiate();

                if (!DefaultTemplateInstantiationScope.IsActive)
                {
                    var launchPoint = this.FindLaunchPoint();
                    if (launchPoint != null)
                    {
                        // There is an issue in all versions of VS up to and including VS2008 SP1
                        // that won't allow the expansion of a multi-project template unless the Solution node in the Solution explorer
                        // is selected.  The code below works for any solution with less than 100,000 items
                        this.Solution.SelectUp();

                        this.UnfoldDefaultTemplate(launchPoint);
                    }
                }
            }
        }
示例#11
0
        /// <summary>
        /// Gets whether the given guidance extension has been instantiated in the solution.
        /// </summary>
        public static bool IsInstantiated(this IGuidanceManager manager, string extensionId, string instanceName)
        {
            Guard.NotNull(() => manager, manager);
            Guard.NotNullOrEmpty(() => extensionId, extensionId);
            Guard.NotNullOrEmpty(() => instanceName, instanceName);

            return(FindInstance(manager, extensionId, instanceName) != null);
        }
示例#12
0
        public static string GetUniqueInstanceName(this IGuidanceManager guidanceManager, string baseName)
        {
            Guard.NotNull(() => guidanceManager, guidanceManager);
            Guard.NotNull(() => baseName, baseName);

            return(UniqueNameGenerator.EnsureUnique(baseName,
                                                    newName => !guidanceManager.InstantiatedGuidanceExtensions.Any(ge => ge.InstanceName.Equals(newName, StringComparison.OrdinalIgnoreCase))));
        }
        internal GuidanceContentUriReferenceProvider(SVsServiceProvider serviceProvider, IGuidanceManager guidanceManager)
        {
            Guard.NotNull(() => serviceProvider, serviceProvider);
            Guard.NotNull(() => guidanceManager, guidanceManager);

            this.ServiceProvider = serviceProvider;
            this.guidanceManager = guidanceManager;
        }
示例#14
0
 public void Initialize()
 {
     this.guidanceManager = VsIdeTestHostContext.ServiceProvider.GetService<IGuidanceManager>();
     this.guidanceManager.ActiveGuidanceExtension = null;
     this.launchService = VsIdeTestHostContext.ServiceProvider.GetService<IShortcutLaunchService>();
     this.solution = VsIdeTestHostContext.ServiceProvider.GetService<ISolution>();
     this.solution.Open(this.PathTo(@"Runtime.IntegrationTests.Content\Shortcuts\Shortcuts.sln"));
     this.solutionItemsFolder = this.solution.SolutionFolders.Single(sf => sf.Name == NuPattern.VisualStudio.Solution.SolutionExtensions.SolutionItemsFolderName);
 }
示例#15
0
        /// <summary>
        /// Gets the instance with given name and extension
        /// </summary>
        public static IGuidanceExtension FindInstance(this IGuidanceManager manager, string extensionId, string instanceName)
        {
            Guard.NotNull(() => manager, manager);
            Guard.NotNullOrEmpty(() => extensionId, extensionId);
            Guard.NotNullOrEmpty(() => instanceName, instanceName);

            return(manager.InstantiatedGuidanceExtensions.FirstOrDefault(ge => ge.ExtensionId.Equals(extensionId, StringComparison.OrdinalIgnoreCase) &&
                                                                         ge.InstanceName.Equals(instanceName, StringComparison.OrdinalIgnoreCase)));
        }
示例#16
0
 public void Initialize()
 {
     this.guidanceManager = VsIdeTestHostContext.ServiceProvider.GetService <IGuidanceManager>();
     this.guidanceManager.ActiveGuidanceExtension = null;
     this.launchService = VsIdeTestHostContext.ServiceProvider.GetService <IShortcutLaunchService>();
     this.solution      = VsIdeTestHostContext.ServiceProvider.GetService <ISolution>();
     this.solution.Open(this.PathTo(@"Runtime.IntegrationTests.Content\Shortcuts\Shortcuts.sln"));
     this.solutionItemsFolder = this.solution.SolutionFolders.Single(sf => sf.Name == NuPattern.VisualStudio.Solution.SolutionExtensions.SolutionItemsFolderName);
 }
示例#17
0
        /// <summary>
        /// Creates a new instance of the <see cref="VsLaunchPoint"/> class.
        /// </summary>
        /// <param name="guidanceManager"></param>
        /// <param name="id"></param>
        protected VsLaunchPoint(IGuidanceManager guidanceManager, CommandID id)
            : base(OnExecute, id)
        {
            Guard.NotNull(() => guidanceManager, guidanceManager);

            this.BeforeQueryStatus += this.OnBeforeQueryStatus;
            this.GuidanceManager = guidanceManager;
            this.QueryStatusStrategy = new DefaultQueryStatusStrategy(this.GetType().Name);
            this.GuidanceInstanceLocator = new DefaultGuidanceInstanceLocator(guidanceManager, this.GetType());
        }
示例#18
0
        /// <summary>
        /// Creates a new instance of the <see cref="VsLaunchPoint"/> class.
        /// </summary>
        /// <param name="guidanceManager"></param>
        /// <param name="id"></param>
        protected VsLaunchPoint(IGuidanceManager guidanceManager, CommandID id)
            : base(OnExecute, id)
        {
            Guard.NotNull(() => guidanceManager, guidanceManager);

            this.BeforeQueryStatus      += this.OnBeforeQueryStatus;
            this.GuidanceManager         = guidanceManager;
            this.QueryStatusStrategy     = new DefaultQueryStatusStrategy(this.GetType().Name);
            this.GuidanceInstanceLocator = new DefaultGuidanceInstanceLocator(guidanceManager, this.GetType());
        }
示例#19
0
        protected VsTemplateLaunchPoint(IGuidanceManager guidanceManager, string id, string name, string category)
        {
            Guard.NotNull(() => guidanceManager, guidanceManager);

            this.GuidanceManager = guidanceManager;
            this.Id       = id;
            this.Name     = name;
            this.Category = category;

            this.QueryStatusStrategy     = new DefaultQueryStatusStrategy(this.GetType().Name);
            this.GuidanceInstanceLocator = new DefaultGuidanceInstanceLocator(guidanceManager, this.GetType());
        }
示例#20
0
        public GuidanceExplorerViewModel(GuidanceWorkflowContext context, IServiceProvider serviceProvider)
        {
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => serviceProvider, serviceProvider);

            this.context         = context;
            this.serviceProvider = serviceProvider;
            this.guidanceManager = context.GuidanceManager;
            this.Workflows       = new ObservableCollection <GuidanceWorkflowViewModel>();
            this.SubscribeToExtensionChanges(guidanceManager);
            this.InitializeCommands();
        }
        public GuidanceBrowserViewModel(GuidanceBrowserContext context, IServiceProvider serviceProvider)
        {
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => serviceProvider, serviceProvider);

            this.context         = context;
            this.serviceProvider = serviceProvider;

            this.NavigationCommand   = new RelayCommand <Uri>(uri => this.Navigate(uri));
            this.guidanceManager     = context.GuidanceManager;
            this.uriReferenceService = context.UriReferenceService;
        }
        public GuidanceExplorerViewModel(GuidanceWorkflowContext context, IServiceProvider serviceProvider)
        {
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => serviceProvider, serviceProvider);

            this.context = context;
            this.serviceProvider = serviceProvider;
            this.guidanceManager = context.GuidanceManager;
            this.Workflows = new ObservableCollection<GuidanceWorkflowViewModel>();
            this.SubscribeToExtensionChanges(guidanceManager);
            this.InitializeCommands();
        }
        protected VsTemplateLaunchPoint(IGuidanceManager guidanceManager, string id, string name, string category)
        {
            Guard.NotNull(() => guidanceManager, guidanceManager);

            this.GuidanceManager = guidanceManager;
            this.Id = id;
            this.Name = name;
            this.Category = category;

            this.QueryStatusStrategy = new DefaultQueryStatusStrategy(this.GetType().Name);
            this.GuidanceInstanceLocator = new DefaultGuidanceInstanceLocator(guidanceManager, this.GetType());
        }
示例#24
0
        public static void ShowGuidanceWindows(this IGuidanceManager guidanceManager, IServiceProvider provider)
        {
            Guard.NotNull(() => guidanceManager, guidanceManager);
            Guard.NotNull(() => provider, provider);

            var toolWindows = provider.GetService <IPatternWindows>();

            if (toolWindows != null)
            {
                tracer.Verbose(Resources.GuidanceManagerExtensions_TraceShowingGuidanceWindows);

                toolWindows.ShowGuidanceExplorer(provider);
                toolWindows.ShowGuidanceBrowser(provider);
            }
        }
示例#25
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;
        }
示例#26
0
        /// <summary>
        /// Initializes the guidance extension.
        /// </summary>
        /// <param name="registration">The guidance extension registration information, which includes its identifier and manifest information..</param>
        /// <param name="instanceName">Name of the instance.</param>
        /// <param name="version">The version of the guidance extension to intialize</param>
        /// <param name="guidanceManager">An instance of the <see cref="IGuidanceManager"/></param>
        /// <remarks>
        /// This method is called after <see cref="Instantiate"/>
        /// when a guidance extension is first initialized in a solution,
        /// or after reopening a solution where the feature
        /// had been previously instantiated.
        /// </remarks>
        public void Initialize(IGuidanceExtensionRegistration registration, string instanceName, Version version, IGuidanceManager guidanceManager)
        {
            this.ExtensionId  = registration.ExtensionId;
            this.InstanceName = instanceName;
            this.Registration = registration;
            //
            // note we do this here and in Instantiate because when re-opening a solution, we never call Instantiate
            //
            this.guidanceManager = guidanceManager;

            this.Trace = Tracer.Get(this.GetType());

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

            this.OnInitialize(version);
        }
示例#27
0
        private void SubscribeToExtensionChanges(IGuidanceManager guidanceManager)
        {
            guidanceManager.InstantiatedExtensionsChanged += (s, e) => this.SetWorkflows(guidanceManager.InstantiatedGuidanceExtensions);
            this.SetWorkflows(guidanceManager.InstantiatedGuidanceExtensions);

            guidanceManager.ActiveExtensionChanged += (s, e) =>
            {
                if (guidanceManager.ActiveGuidanceExtension == null)
                {
                    this.CurrentWorkflow = null;
                }
                else
                {
                    if (guidanceManager.ActiveGuidanceExtension.GuidanceWorkflow != null)
                    {
                        this.CurrentWorkflow = this.Workflows.FirstOrDefault(w => w.Model == guidanceManager.ActiveGuidanceExtension.GuidanceWorkflow);
                        GuidanceConditionsEvaluator.EvaluateGraph(guidanceManager.ActiveGuidanceExtension);
                    }
                }
            };
        }
示例#28
0
        public static IGuidanceExtension InstantiateGuidanceInstance(this IGuidanceManager guidanceManager, IServiceProvider provider, string extensionId, string instanceName)
        {
            Guard.NotNull(() => guidanceManager, guidanceManager);
            Guard.NotNull(() => provider, provider);
            Guard.NotNullOrEmpty(() => extensionId, extensionId);

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

            tracer.Info(Resources.GuidanceManagerExtensions_TraceInstantiation, extensionId, instanceName);

            // Create a new instance of guidance workflow
            var instance = guidanceManager.Instantiate(extensionId, instanceName);

            // Activate guidance extension in Guidance Explorer
            guidanceManager.ActiveGuidanceExtension = instance;

            return(instance);
        }
 public void InitializeContext()
 {
     this.guidanceManager = (IGuidanceManager)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IGuidanceManager));
 }
示例#30
0
 public static IEnumerable <IGuidanceExtension> GetResolvedReferences(IProductElement element, IGuidanceManager guidanceManager)
 {
     return(GetResolvedReferences(element, guidanceManager, r => true));
 }
示例#31
0
 /// <summary>
 /// Gets whether the given guidance extension has been instantiated in the solution.
 /// </summary>
 public static bool IsInstantiated(this IGuidanceManager manager, IGuidanceExtensionRegistration registration)
 {
     return(manager.IsInstantiated(registration.ExtensionId));
 }
示例#32
0
        public static IEnumerable <IGuidanceExtension> GetResolvedReferences(IProductElement element, IGuidanceManager guidanceManager, Func <IReference, bool> whereFilter)
        {
            Guard.NotNull(() => element, element);
            Guard.NotNull(() => guidanceManager, guidanceManager);
            Guard.NotNull(() => whereFilter, whereFilter);

            return(GetReferenceValues(element, whereFilter)
                   .Select(reference => guidanceManager.InstantiatedGuidanceExtensions.FirstOrDefault(f => f.InstanceName.Equals(reference, StringComparison.OrdinalIgnoreCase)))
                   .Where(item => item != null));
        }
        /// <summary>
        /// Instantiates the guidance extension in a solution.
        /// </summary>
        /// <param name="registration">The guidance extension registration information, which includes its identifier and manifest information..</param>
        /// <param name="instanceName">Name of the instance.</param>
        /// <param name="guidanceManager">An instance of the <see cref="IGuidanceManager"/></param>
        /// <remarks>
        /// This method is called when a feature is first instantiated in a solution.
        /// </remarks>
        public void Instantiate(IGuidanceExtensionRegistration registration, string instanceName, IGuidanceManager guidanceManager)
        {
            using (new GuidanceExtensionInstantiationScope())
            {
                this.ExtensionId = registration.ExtensionId;
                this.guidanceManager = guidanceManager;
                this.InstanceName = instanceName;
                this.Registration = registration;
                this.Trace = Tracer.Get(this.GetType());

                this.OnInstantiate();

                if (!DefaultTemplateInstantiationScope.IsActive)
                {
                    var launchPoint = this.FindLaunchPoint();
                    if (launchPoint != null)
                    {
                        // There is an issue in all versions of VS up to and including VS2008 SP1
                        // that won't allow the expansion of a multi-project template unless the Solution node in the Solution explorer
                        // is selected.  The code below works for any solution with less than 100,000 items
                        this.Solution.SelectUp();

                        this.UnfoldDefaultTemplate(launchPoint);
                    }
                }
            }
        }
示例#34
0
 /// <summary>
 /// Creates a new instance of the <see cref="LinkLaunchPoint"/> class.
 /// </summary>
 protected LinkLaunchPoint(IGuidanceManager guidanceManager)
 {
     Guard.NotNull(() => guidanceManager, guidanceManager);
     GuidanceManager          = guidanceManager;
     this.QueryStatusStrategy = new DefaultQueryStatusStrategy(this.GetType().Name);
 }
        private void SubscribeToExtensionChanges(IGuidanceManager guidanceManager)
        {
            guidanceManager.InstantiatedExtensionsChanged += (s, e) => this.SetWorkflows(guidanceManager.InstantiatedGuidanceExtensions);
            this.SetWorkflows(guidanceManager.InstantiatedGuidanceExtensions);

            guidanceManager.ActiveExtensionChanged += (s, e) =>
            {
                if (guidanceManager.ActiveGuidanceExtension == null)
                    this.CurrentWorkflow = null;
                else
                {
                    if (guidanceManager.ActiveGuidanceExtension.GuidanceWorkflow != null)
                    {
                        this.CurrentWorkflow = this.Workflows.FirstOrDefault(w => w.Model == guidanceManager.ActiveGuidanceExtension.GuidanceWorkflow);
                        GuidanceConditionsEvaluator.EvaluateGraph(guidanceManager.ActiveGuidanceExtension);
                    }
                }
            };
        }
 public DefaultGuidanceInstanceLocator(IGuidanceManager guidanceManager, Type componentType)
 {
     this.guidanceManager = guidanceManager;
     this.componentType   = componentType;
 }
        /// <summary>
        /// Initializes the guidance extension.
        /// </summary>
        /// <param name="registration">The guidance extension registration information, which includes its identifier and manifest information..</param>
        /// <param name="instanceName">Name of the instance.</param>
        /// <param name="version">The version of the guidance extension to intialize</param>
        /// <param name="guidanceManager">An instance of the <see cref="IGuidanceManager"/></param>
        /// <remarks>
        /// This method is called after <see cref="Instantiate"/>
        /// when a guidance extension is first initialized in a solution,
        /// or after reopening a solution where the feature
        /// had been previously instantiated.
        /// </remarks>
        public void Initialize(IGuidanceExtensionRegistration registration, string instanceName, Version version, IGuidanceManager guidanceManager)
        {
            this.ExtensionId = registration.ExtensionId;
            this.InstanceName = instanceName;
            this.Registration = registration;
            //
            // note we do this here and in Instantiate because when re-opening a solution, we never call Instantiate
            //
            this.guidanceManager = guidanceManager;

            this.Trace = Tracer.Get(this.GetType());

            this.GuidanceWorkflow = this.CreateWorkflow();
            if (this.GuidanceWorkflow != null)
                this.GuidanceWorkflow.OwningExtension = this;

            this.OnInitialize(version);
        }
 public InstantiatePatternToolkitLink(IGuidanceManager guidanceManager)
     : base(guidanceManager)
 {
 }
示例#39
0
 /// <summary>
 /// Creates a new instance of the <see cref="LinkLaunchPoint"/> class.
 /// </summary>
 protected LinkLaunchPoint(IGuidanceManager guidanceManager)
 {
     Guard.NotNull(() => guidanceManager, guidanceManager);
     GuidanceManager = guidanceManager;
     this.QueryStatusStrategy = new DefaultQueryStatusStrategy(this.GetType().Name);
 }
示例#40
0
 public void InitializeContext()
 {
     this.guidanceManager = (IGuidanceManager)VsIdeTestHostContext.ServiceProvider.GetService(typeof(IGuidanceManager));
 }
 public DefaultGuidanceInstanceLocator(IGuidanceManager guidanceManager, Type componentType)
 {
     this.guidanceManager = guidanceManager;
     this.componentType = componentType;
 }
 public InstantiateUsingGuidanceLink(IGuidanceManager guidanceManager)
     : base(guidanceManager, CommandBindingName)
 {
 }
 public InstantiatePatternToolkitLink(IGuidanceManager guidanceManager)
     : base(guidanceManager)
 {
 }
 public InstantiateUsingGuidanceLink(IGuidanceManager guidanceManager)
     : base(guidanceManager, CommandBindingName)
 {
 }