CampusNexus Visual Studio Item Templates

The CampusNexus Visual Studio item templates are a set of templates that will help you create common CampusNexus .NET types such as Services, Events, Commands, and EventHandlers.  To assist in maintaining naming and namespace consistency across CampusNexus, these templates are designed to be executed to the root of your projects.  To use a template, right click on your project and select Add -> New Item… -> CampusNexus.

templateAddItem

Installation

Set User Item Templates Location

  1. Within Visual Studio, navigate to: Tools -> Options -> Projects and Solutions -> General
  2. Set the User item templates location to: \\bcrnfs1\departments\Development\Visual Studio\Templates\ItemTemplates

templateInstallation

Copy Cmc.VisualStudio.Templates.dll

Visual Studio 2013

Copy:
\\bcrnfs1\departments\Development\Visual Studio\Cmc.VisualStudio.Templates.dll
To:
%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies

Visual Studio 2015

Copy:
\\bcrnfs1\departments\Development\Visual Studio\Cmc.VisualStudio.Templates.dll
To:
%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE\PublicAssemblies

Visual Studio Item Templates

Contract: Service Event

The Service Event multi-item template will create four source files:

Event Type

The event type inherits Event<T> where T is the type of your event args (e.g. DropCourseEvent<DropCourseEventArgs>.  This type will be used to raise an event or register an event handler.  As part of the generation of the event type, the template will create a code snippet that you can copy into your service implementation to allow you to raise the event.

EventArgs Type

The event args represent the arguments you will pass when you raise the event using the EventService.  These arguments will be available within an event handler or workflow.

Request Type

Represents the argument to your service method that will be raising the event.

Response Type

Represents the return value for your service method that will be raising the event.

Project: Contracts (e.g. Cmc.Nexus.Academics.Contracts)

Naming Convention: The name of the generated types is based on the Method/Verb you pick.

templateServiceEvent

Contract: Service Interface

The Service Interface template will create an empty interface for your Service.  When using the template wizard you will have the option of creating an interface that inherits IEntityService<T> or IService.

  • An IEntityService<T> interface will provide CRUD operations for the entity type specified in the wizard dialog.
  • An IService interface will provide no base functionality and is typically used for non-entity based services

Project: Contracts (e.g. Cmc.Nexus.Academics.Contracts)

Naming Convention: IServiceName (e.g. IStudentCourseService)

templateServiceInterface

 Contract: Service Request/Response

The Service Request multi-item template will create a type derived from ServiceRequest and a type derived from ServiceResponse.  These types should be used to define the method signature of your service.
Project: Contracts (e.g. Cmc.Nexus.Academics.Contracts)

Naming Convention: MethodName (e.g. DropCourse)

Implementation: Entity Service Command

The Entity Service Command template is used to create CRUD commands to expose your service methods through the Web API.

Project: Implementation (e.g. Cmc.Nexus.Academics)

Naming Convention: The naming convention is based on the Entity Type you choose within the wizard dialog.

templateServiceCommand

Your folder structure should look like this:

The output of the implemented files are below:

Implementation: Event Handler

The Event Handler template will create an empty event handler for an Entity or Service Interface.  The Type should be either an Entity (e.g. StudentCourseEntity) to handle CRUD based events or a Service interface (e.g. IStudentCourseService) to handle method-based events.

templateEventHandler

Implementation: Service

The Service template will create an empty implementation for your Service.  When using the template wizard you will have the option of creating an implementation that inherits EntityService<T> or Service.

  • An EntityService<T> implementation will provide CRUD operations for the entity type specified in the wizard dialog.
  • A Service implementation will provide no base functionality and is typically used for non-entity based services

Project: Contracts (e.g. Cmc.Nexus.Academics)

Naming Convention: ServiceName (e.g. StudentCourseService)

templateService

One thought on “CampusNexus Visual Studio Item Templates

Leave a Reply

Skip to toolbar