Giter Site home page Giter Site logo

quarantinetemplate's Introduction

Quarantine Template

This repository contains an extensive Visual Studio project template and an item template creation example.

What does this repository contain and what will you see?

  1. How to create VSIX project?
  2. How to create an item template project?
  3. How to create a project template project?
  4. How to use Custom parameters in an item template or project template?
  5. How to implementation IWizard interface?
  6. How to create a form and how to shown this form when create an item?
  7. How to debug VSIX project?

Quarantine Template Project Structure

Project Name Project Type
QuarantineTemplate.sln Blank Solution
QuarantineTemplate VSIX Project Startup Project
QuarantineEntityTemplate C# Item Template Project
QuarantineRepositoryTemplate C# Item Template Project
QuarantineWizard Class Library (.NET Framework 4.8)

Quarantine Template Directory Structure

    ├── QuarantineTemplate
    │   ├── src
    │   │   ├── QuarantineTemplate
    │   │   │   └── QuarantineTemplatePackage.cs
    │   │   │   └── source.extension.vsixmanifest
    │   │   ├── QuarantineEntityTemplate
    │   │   │   └── Entity.cs
    │   │   │   └── EntityTemplate.ico
    │   │   │   └── EntityTemplate.vstemplate
    │   │   ├── QuarantineRepositoryTemplate
    │   │   │   └── ...
    │   │   ├── QuarantineWizard
    │   │   │   ├── ItemComponents
    │   │   │   │   ├── EntityClassComponent
    │   │   │   │   │   └── FormEntityClassComponet.cs    
    │   │   │   ├── Wizards
    │   │   │   │   └── WizardEntityClass.cs
    │   ├── files
    │   └── QuarantineTemplate.sln
    │   └── README.md
    │   └── LICENSE
    │   └── .gitignore

Creating the Visual Studio extension project

  1. Create a new VSIX project within Visual Studio (New Project / Visual C# / Extensions) (VS2019)
  2. Select VSIX Project.
  3. QuarantineTemplate is a VSIX Project.

Creating the Visual Studio item template project

  1. Create a new C# Item Template Project within Visual Studio (New Project / Visual C# / Extensions) (VS2019)
  2. Select C# Item Template.
  3. QuarantineEntityTemplate and QuarantineRepositoryTemplate are C# Item Template projects.

How to implementation IWizard interface?

Create an Class Library and install VSSDK.TemplateWizardInterface from nuget. Add a class and this class is inherit from the IWizard interface.

using EnvDTE;
using Microsoft.VisualStudio.TemplateWizard;
using QuarantineWizard.ItemComponents.EntityClassComponent;
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;

namespace QuarantineWizard.Wizards
{
    public class WizardEntityClass : IWizard
    {
        private readonly FormEntityClassComponet _form = new FormEntityClassComponet();
        private bool _userCancelled;
        private DTE _currnetDte;
        private static string _currentSolutionPath;

        public void BeforeOpeningFile(ProjectItem projectItem)
        {

        }

        public void ProjectFinishedGenerating(Project project)
        {

        }

        public void ProjectItemFinishedGenerating(ProjectItem projectItem)
        {

        }

        public bool ShouldAddProjectItem(string filePath)
        {
            return !_userCancelled;
        }


        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            _currnetDte = (DTE)automationObject;
            _currentSolutionPath = replacementsDictionary["$solutiondirectory$"];

            using (_form)
            {
                _form.StrFormTitle = Path.GetFileName(replacementsDictionary["$title$"]);
                _form.StrEntityClassName = Path.GetFileName(replacementsDictionary["$safeitemrootname$"]);
                _form.StrEntitySchemaName = Path.GetFileName(replacementsDictionary["$schemaname$"]);
                _form.StrEntityIdTypeName = Path.GetFileName(replacementsDictionary["$idtype$"]);
                if (_form.ShowDialog() != DialogResult.OK)
                {
                    _userCancelled = true;
                    return;
                }

                replacementsDictionary["$schemaname$"] = _form.StrEntitySchemaName;
                replacementsDictionary["$idtype$"] = _form.StrEntityIdTypeName;
            }
        }
        public void RunFinished()
        {

        }
    }
}

To use this project in the item template or the project template, the key.snk file must be created.

Read this more information

How read your key.snk public token. It's easy with Visual Studio. Add new an external tool. Visual Studi -> Tools -> External Tools and open external tools window.

Now run added external tool and get token.

The token will use on project template or item template .vstemplate files.

EntityTemplate.vstemplate file Wizard project dll usage

How debug solution.

  1. Create a new console application in a directory close to your project.
    ├── Projects
    │   ├── QuarantineTemplate
    │   ├── QuarantineTemplateDebugger
    │   │   └── QuarantineTemplateDebugger.sln
  1. Open QuarantineTemplate properties debug tab and configure like this.

quarantinetemplate's People

Contributors

ozturkfatih avatar

Stargazers

Mustafa KÖLELİ avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.