Partager via


FlavoredProjectFactoryBase Class

Base class for flavored project factories.

Inheritance Hierarchy

Object
  Microsoft.VisualStudio.Shell.Flavor.FlavoredProjectFactoryBase

Namespace:  Microsoft.VisualStudio.Shell.Flavor
Assembly:  Microsoft.VisualStudio.Shell.12.0 (in Microsoft.VisualStudio.Shell.12.0.dll)

Syntax

'Declaration
Public MustInherit Class FlavoredProjectFactoryBase _
    Implements IVsAggregatableProjectFactoryCorrected, IVsProjectFactory
public abstract class FlavoredProjectFactoryBase : IVsAggregatableProjectFactoryCorrected, 
    IVsProjectFactory
public ref class FlavoredProjectFactoryBase abstract : IVsAggregatableProjectFactoryCorrected, 
    IVsProjectFactory
[<AbstractClass>]
type FlavoredProjectFactoryBase =  
    class 
        interface IVsAggregatableProjectFactoryCorrected 
        interface IVsProjectFactory 
    end
public abstract class FlavoredProjectFactoryBase implements IVsAggregatableProjectFactoryCorrected, IVsProjectFactory

The FlavoredProjectFactoryBase type exposes the following members.

Constructors

  Name Description
Public method FlavoredProjectFactoryBase Initializes a new instance of FlavoredProjectFactoryBase.

Top

Properties

  Name Description
Protected property serviceProvider Gets the project's service provider.

Top

Methods

  Name Description
Protected method CanCreateProject Determines whether or not the project can be created with the supplied parameters.
Protected method CreateProject Creates a project.
Protected method Dispose Disposes the service provider.
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as the default hash function. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method Initialize Initializes the project factory.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method PreCreateForOuter Creates an instance of the project.
Protected method ProjectTypeGuids Gets the set of project type GUIDs from the project file.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IVsAggregatableProjectFactoryCorrected.GetAggregateProjectType
Explicit interface implemetationPrivate method IVsAggregatableProjectFactoryCorrected.PreCreateForOuter
Explicit interface implemetationPrivate method IVsProjectFactory.CanCreateProject
Explicit interface implemetationPrivate method IVsProjectFactory.Close
Explicit interface implemetationPrivate method IVsProjectFactory.CreateProject
Explicit interface implemetationPrivate method IVsProjectFactory.SetSite

Top

Remarks

An implementation of a flavored project factory is defined by FlavoredProjectFactory. Override the PreCreateForOuter method to return a new FlavoredProjectBase derived class. The derived class GetGuidProperty method can redirect the templates search to find new project templates for this flavor.

Examples

namespace Microsoft.Samples.VisualStudio.IronPythonProject.WPFProviders
{
    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.None)]
    [Guid("FEBF49B8-D18C-4745-ADE0-35BF632E0533")]
    public class PythonWPFFlavor : FlavoredProjectBase
    {
        public PythonWPFFlavor(IServiceProvider site)
        {
            this.serviceProvider = site;
        }

        protected override Guid GetGuidProperty(uint itemId, int propId)
        {
            if (propId == 
                (int)__VSHPROPID2.VSHPROPID_AddItemTemplatesGuid)
            {
                return typeof(PythonWPFProjectFactory).GUID;
            }
            return base.GetGuidProperty(itemId, propId);
        }

        protected override int GetProperty(uint itemId, int propId, out object property)
        {
            return base.GetProperty(itemId, propId, out property);
        }
    }
    [Guid(PythonWPFProjectFactory.PythonWPFProjectFactoryGuid)]
    public class PythonWPFProjectFactory : FlavoredProjectFactoryBase
    {
        public const string PythonWPFProjectFactoryGuid = "229B3E77-97E9-4f6d-9151-E6D103EA4D4A";

        private IServiceProvider site;
        public PythonWPFProjectFactory(IServiceProvider site) : base()
        {
            this.site = site;
        }

        protected override object PreCreateForOuter(IntPtr outerProjectIUnknown)
        {
            return new PythonWPFFlavor(site);
        }
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualStudio.Shell.Flavor Namespace