Vault Application Framework code snippets for Visual Studio
See Installing using the Visual Studio Template Package.
Visual Studio Code Snippets are small blocks of reusable code that can be inserted into a code file using a context menu or set of key-presses. Code Snippets can be used to quickly create commonly-used code structures such as methods or properties, reducing the amount of code that developers must type to do so.
Code Snippets consist of a block of standardised text, and small editable sections. When a snippet is first entered, the editable sections are highlighted and the user can overtype the values to customise the code snippet. The developer can move between the editable elements of the snippet by pressing Tab
, and press Enter
or Esc
to finish editing.
Executing Code Snippets
Using the keyboard
To execute a Code Snippet, the developer types the name of the code snippet (e.g. prop
) and presses Tab
twice. Visual Studio then executes the snippet and places it at the current location.
Resharper can alter the standard keyboard shortcuts. If you are using Resharper then You must press Ctrl-J
, then type the code snippet name. The other keyboard shortcuts still work.
Using the mouse
To execute the code snippet, the developer right-clicks at the appropriate place in the code file and selects Insert Code Snippet...
. The available code snippets are listed in a folder-style structure. The developer can double-click on the required Code Snippet and fill out the editable elements of the snippet by pressing Tab
.
Code Snippets and the Vault Application Framework
When developing applications using the Vault Application Framework it is common to create methods that are executed in response to various events within the vault, such as an object reaching a state in a workflow, or a property value requiring validation. Attributes are used to ensure that the Vault Application Framework knows which methods need to be executed at what time. These attributes often require the following method to have a specific signature in order to function; if the method does not match the expected signature then it will not be invoked.
The Vault Application Framework Attributes page details the attributes and their expected method signature, if appropriate.
Code Snippets can be used to automatically generate class members (methods and properties) with the correct structure and signatures, reducing development time.
Contributing to the Code Snippets
To contribute additional code snippets or to fix issues with existing code snippets, please visit the GitHub Samples and Libraries repository, fork the repository, make the required changes, then submit a pull request. GitHub has further information on forking and pull requests.
Available Code Snippets
See Installing using the Visual Studio Template Package.
The following code snippets exist. Once the snippets are installed, simply type their name within a code file, select the snippet, and press Tab
twice.
Properties
MFVAFPropertyAutomaticNumber
creates a code snippet for PropertyAutomaticNumberingAttribute.MFVAFPropertyCustomValue
creates a code snippet for PropertyCustomValueAttribute.MFVAFPropertyValidation
creates a code snippet for PropertyValueValidationAttribute.
Vault Extension Methods
MFVAFVaultExtensionMethod
creates a code snippet for VaultExtensionMethodAttribute.
Workflows
MFVAFStateAction
creates a code snippet for StateActionAttribute.MFVAFStatePreCondition
creates a code snippet for StatePreConditionsAttribute.MFVAFStatePostCondition
creates a code snippet for StatePostConditionsAttribute.MFVAFAutomaticStateTransitionTrigger
creates a code snippet for AutomaticStateTransitionTriggerAttribute.
Event Handlers
MFVAFEventHandler
creates a code snippet for EventHandlerAttribute.
Vault Structural Elements (MFIdentifiers)
MFVAFClassGroupIdentifier
creates a code snippet for a MFIdentifier with aMFVAFClassGroupAttribute
.MFVAFClassIdentifier
creates a code snippet for a MFIdentifier with aMFVAFClassAttribute
.MFVAFObjectTypeIdentifier
creates a code snippet for a MFIdentifier with aMFVAFObjTypeAttribute
.MFVAFValueListIdentifier
creates a code snippet for a MFIdentifier with aMFVAFValueListAttribute
.MFVAFValueListItemIdentifier
creates a code snippet for a MFIdentifier with aMFVAFValueListItemAttribute
.MFVAFNamedAccessControlListIdentifier
creates a code snippet for a MFIdentifier with aMFVAFNamedACL
.MFVAFUserGroupIdentifier
creates a code snippet for a MFIdentifier with aMFVAFUserGroupAttribute
.MFVAFPropertyDefinitionIdentifier
creates a code snippet for a MFIdentifier with aMFVAFPropertyDefAttribute
.MFVAFWorkflowIdentifier
creates a code snippet for a MFIdentifier with aMFVAFWorkflowAttribute
.MFVAFWorkflowStateIdentifier
creates a code snippet for a MFIdentifier with aMFVAFStateAttribute
.MFVAFWorkflowStateTransitionIdentifier
creates a code snippet for a MFIdentifier with aMFVAFStateTransitionAttribute
.MFVAFViewIdentifier
creates a code snippet for a MFIdentifier with aMFVAFViewAttribute
.
Configuration
MFVAFConfiguration
creates a code snippet for a property with aMFVAFConfigurationAttribute
.
Installing the Vault Application Framework Code Snippets
Installing using the Visual Studio Template Package
Code Snippets are included in the M-Files Online Visual Studio Template Package. Installing this package also installs the code snippets listed here.
The package can be uninstalled by opening Visual Studio, clicking Tools
, then Extensions and Updates...
, as with other installed extensions.
Downloading the raw snippet files (not recommended)
The raw snippet files are available for download within our GitHub Samples and Libraries repository. To install the snippets manually:
- Download the
.snippet
file(s). - Open Visual Studio.
- Click the
Tools
menu item and selectCode Snippets Manager
. - Click
Add
and locate the downloaded.snippet
file.