Example #1
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);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Initiailizes the given extension
        /// </summary>
        /// <remarks>Semi-public version which allows control over call to postInitialize</remarks>
        protected IGuidanceExtension InitializeExtension(string extensionId,
                                                         string instanceName,
                                                         IGuidanceExtensionRegistration registration,
                                                         Version version,
                                                         bool isInstantiation
                                                         )
        {
            var extensionInstance = this.CreateExtension(extensionId);
            var composition       = this.CreateCompositionService(extensionInstance, extensionId);

            //
            // Let's check to see if the instantiation should be registered with the
            // solution
            if (extensionInstance.PersistInstanceInSolution)
            {
                solutionState.AddExtension(extensionId, instanceName, version);
            }

            if (isInstantiation)
            {
                extensionInstance.Instantiate(registration, instanceName, this);
            }
            else
            {
                extensionInstance.Initialize(registration, instanceName, version, this);
                instantiatedGuidanceExtensions.Add(new Tuple <IGuidanceExtension, INuPatternCompositionService>(extensionInstance, composition));
                InstantiatedExtensionsChanged(this, EventArgs.Empty);
                RaisePropertyChanged(x => x.InstantiatedGuidanceExtensions);
            }

            return(extensionInstance);
        }
Example #3
0
        public IGuidanceExtension CreateExtension(IGuidanceExtensionRegistration registration)
        {
            // We re-retrieve the export rather than caching the one
            // we got from ExportedExtensions as we need to
            // lazily re-evaluate the export as it's a non-shared
            // component that needs to be re-created every time.
            // If we cache the export, we're basically caching the
            // lazy instance for *one* particular instantiation.
            var extension = NuPatternGlobalContainer.Instance
                            .GetExports <IGuidanceExtension, IGuidanceExtensionMetadata>()
                            .FirstOrDefault(e => e.Metadata.ExtensionId == registration.ExtensionId);

            return(extension != null ? extension.Value : null);
        }
Example #4
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);
        }
        /// <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);
        }
        /// <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);
                    }
                }
            }
        }
Example #7
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));
 }
        /// <summary>
        /// Initiailizes the given extension
        /// </summary>
        /// <remarks>Semi-public version which allows control over call to postInitialize</remarks>
        protected IGuidanceExtension InitializeExtension(string extensionId,
            string instanceName,
            IGuidanceExtensionRegistration registration,
            Version version,
            bool isInstantiation
            )
        {
            var extensionInstance = this.CreateExtension(extensionId);
            var composition = this.CreateCompositionService(extensionInstance, extensionId);

            //
            // Let's check to see if the instantiation should be registered with the
            // solution
            if (extensionInstance.PersistInstanceInSolution)
            {
                solutionState.AddExtension(extensionId, instanceName, version);
            }

            if (isInstantiation)
            {
                extensionInstance.Instantiate(registration, instanceName, this);
            }
            else
            {
                extensionInstance.Initialize(registration, instanceName, version, this);
                instantiatedGuidanceExtensions.Add(new Tuple<IGuidanceExtension, INuPatternCompositionService>(extensionInstance, composition));
                InstantiatedExtensionsChanged(this, EventArgs.Empty);
                RaisePropertyChanged(x => x.InstantiatedGuidanceExtensions);
            }

            return extensionInstance;
        }
 /// <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);
 }
 public IGuidanceExtension CreateExtension(IGuidanceExtensionRegistration registration)
 {
     // We re-retrieve the export rather than caching the one 
     // we got from ExportedExtensions as we need to 
     // lazily re-evaluate the export as it's a non-shared 
     // component that needs to be re-created every time.
     // If we cache the export, we're basically caching the 
     // lazy instance for *one* particular instantiation.
     var extension = NuPatternGlobalContainer.Instance
         .GetExports<IGuidanceExtension, IGuidanceExtensionMetadata>()
         .FirstOrDefault(e => e.Metadata.ExtensionId == registration.ExtensionId);
     return extension != null ? extension.Value : null;
 }