This documentation is archived and is not being maintained.

Editor Factories

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

An editor factory creates editor objects and puts them in a window frame, known as a physical view. It is similar to a core class factory for cocreatable COM objects. However, an editor factory creates the document data and document view objects that are necessary to create editors and designers. An editor factory is required to create the Visual Studio core editor and any standard editor. A custom editor can also optionally be created with an editor factory. For more information, see Types of Editors.

An editor factory, represented by the EditorFactory object, is created by implementing the IVsEditorFactory interface. For an example of how to do this, see the Visual C# version of the Reference.SingleViewEditor sample. By default, this sample is located in: C:\Program Files\Visual Studio 2005 SDK\<version number>\VisualStudioIntegration\Samples\IDE\CSharp\Reference.SingleViewEditor.

In the SingleViewEditorFactory.cs file starting on line 29, the following illustrates how to implement IVsEditorFactory to create an editor factory:

[Guid(GuidStrings.guidEditorFactory)]
    public sealed class SingleViewEditorFactory : IVsEditorFactory, 
      IDisposable
    {
        private PackageSingleViewEditor MyPackage;
        private ServiceProvider vsServiceProvider;

        public SingleViewEditorFactory(PackageSingleViewEditor 
          packageEditor)
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, 
              "Entering {0} constructor", this.ToString()));
            MyPackage = packageEditor;
        }

An editor is loaded the first time that you open a file type handled by that editor. You can choose to open either a specific editor or the default editor. If you select the default editor, the integrated development environment (IDE) determines the correct editor to open and then opens it. For more information, see Determining Which Editor Opens a File in a Project and How to: Register Editor Factories.

See Also

Show: