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