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
MFVAFPropertyAutomaticNumbercreates a code snippet for PropertyAutomaticNumberingAttribute.MFVAFPropertyCustomValuecreates a code snippet for PropertyCustomValueAttribute.MFVAFPropertyValidationcreates a code snippet for PropertyValueValidationAttribute.
Vault Extension Methods
MFVAFVaultExtensionMethodcreates a code snippet for VaultExtensionMethodAttribute.
Workflows
MFVAFStateActioncreates a code snippet for StateActionAttribute.MFVAFStatePreConditioncreates a code snippet for StatePreConditionsAttribute.MFVAFStatePostConditioncreates a code snippet for StatePostConditionsAttribute.MFVAFAutomaticStateTransitionTriggercreates a code snippet for AutomaticStateTransitionTriggerAttribute.
Event Handlers
MFVAFEventHandlercreates a code snippet for EventHandlerAttribute.
Vault Structural Elements (MFIdentifiers)
MFVAFClassGroupIdentifiercreates a code snippet for a MFIdentifier with aMFVAFClassGroupAttribute.MFVAFClassIdentifiercreates a code snippet for a MFIdentifier with aMFVAFClassAttribute.MFVAFObjectTypeIdentifiercreates a code snippet for a MFIdentifier with aMFVAFObjTypeAttribute.MFVAFValueListIdentifiercreates a code snippet for a MFIdentifier with aMFVAFValueListAttribute.MFVAFValueListItemIdentifiercreates a code snippet for a MFIdentifier with aMFVAFValueListItemAttribute.MFVAFNamedAccessControlListIdentifiercreates a code snippet for a MFIdentifier with aMFVAFNamedACL.MFVAFUserGroupIdentifiercreates a code snippet for a MFIdentifier with aMFVAFUserGroupAttribute.MFVAFPropertyDefinitionIdentifiercreates a code snippet for a MFIdentifier with aMFVAFPropertyDefAttribute.MFVAFWorkflowIdentifiercreates a code snippet for a MFIdentifier with aMFVAFWorkflowAttribute.MFVAFWorkflowStateIdentifiercreates a code snippet for a MFIdentifier with aMFVAFStateAttribute.MFVAFWorkflowStateTransitionIdentifiercreates a code snippet for a MFIdentifier with aMFVAFStateTransitionAttribute.MFVAFViewIdentifiercreates a code snippet for a MFIdentifier with aMFVAFViewAttribute.
Configuration
MFVAFConfigurationcreates 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
.snippetfile(s). - Open Visual Studio.
- Click the
Toolsmenu item and selectCode Snippets Manager. - Click
Addand locate the downloaded.snippetfile.