Last active
September 1, 2023 03:26
-
-
Save rprouse/d66412307f0d7aaf4e70a2c595819c0b to your computer and use it in GitHub Desktop.
MediatR Visual Studio Code Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
<Title>CreateMediatRCommand</Title> | |
<Author>Rob Prouse</Author> | |
<Description>Create MediatR Command and Handler with no return type</Description> | |
<HelpUrl> | |
</HelpUrl> | |
<Shortcut>mc</Shortcut> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal Editable="true"> | |
<ID>CommandName</ID> | |
<ToolTip>Command name</ToolTip> | |
<Default>CommandName</Default> | |
<Function> | |
</Function> | |
</Literal> | |
</Declarations> | |
<Imports> | |
<Import> | |
<Namespace>System.Threading</Namespace> | |
</Import> | |
<Import> | |
<Namespace>System.Threading.Tasks</Namespace> | |
</Import> | |
<Import> | |
<Namespace>MediatR</Namespace> | |
</Import> | |
<Code Language="csharp" Delimiter="$" Kind="file"><![CDATA[public sealed class $CommandName$Command : IRequest | |
{ | |
} | |
internal sealed class $CommandName$CommandHandler : IRequestHandler<$CommandName$Command> | |
{ | |
public $CommandName$CommandHandler() | |
{ | |
} | |
public async Task<Unit> Handle($CommandName$Command request, CancellationToken cancellationToken) | |
{ | |
throw new NotImplementedException(); | |
} | |
}]]></Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
<Title>CreateMediatRCommandWithReturn</Title> | |
<Author>Rob Prouse</Author> | |
<Description>Create MediatR Command and Handler with a return type</Description> | |
<HelpUrl> | |
</HelpUrl> | |
<Shortcut>mcr</Shortcut> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal Editable="true"> | |
<ID>CommandName</ID> | |
<ToolTip>Command name</ToolTip> | |
<Default>CommandName</Default> | |
<Function> | |
</Function> | |
</Literal> | |
<Literal Editable="true"> | |
<ID>returnType</ID> | |
<ToolTip>Command return type</ToolTip> | |
<Default>TReturn</Default> | |
<Function> | |
</Function> | |
</Literal> | |
</Declarations> | |
<Imports> | |
<Import> | |
<Namespace>System.Threading</Namespace> | |
</Import> | |
<Import> | |
<Namespace>System.Threading.Tasks</Namespace> | |
</Import> | |
<Import> | |
<Namespace>MediatR</Namespace> | |
</Import> | |
</Imports> | |
<Code Language="csharp" Delimiter="$" Kind="file"><![CDATA[public sealed class $CommandName$Command : IRequest<$returnType$> | |
{ | |
} | |
internal sealed class $CommandName$CommandHandler : IRequestHandler<$CommandName$Command, $returnType$> | |
{ | |
public $CommandName$CommandHandler() | |
{ | |
} | |
public async Task<$returnType$> Handle($CommandName$Command request, CancellationToken cancellationToken) | |
{ | |
throw new NotImplementedException(); | |
} | |
}]]></Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
<Title>CreateMediatRQuery</Title> | |
<Author>Rob Prouse</Author> | |
<Description>Create MediatR Query and Handler</Description> | |
<HelpUrl> | |
</HelpUrl> | |
<Shortcut>mq</Shortcut> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal Editable="true"> | |
<ID>QueryName</ID> | |
<ToolTip>Query name</ToolTip> | |
<Default>QueryName</Default> | |
<Function> | |
</Function> | |
</Literal> | |
<Literal Editable="true"> | |
<ID>returnType</ID> | |
<ToolTip>Query return type</ToolTip> | |
<Default>TReturn</Default> | |
<Function> | |
</Function> | |
</Literal> | |
</Declarations> | |
<Imports> | |
<Import> | |
<Namespace>System.Threading</Namespace> | |
</Import> | |
<Import> | |
<Namespace>System.Threading.Tasks</Namespace> | |
</Import> | |
<Import> | |
<Namespace>MediatR</Namespace> | |
</Import> | |
</Imports> | |
<Code Language="csharp" Delimiter="$" Kind="file"><![CDATA[public sealed class $QueryName$Query : IRequest<$returnType$> | |
{ | |
} | |
internal sealed class $QueryName$QueryHandler : IRequestHandler<$QueryName$Query, $returnType$> | |
{ | |
public $QueryName$QueryHandler() | |
{ | |
} | |
public async Task<$returnType$> Handle($QueryName$Query request, CancellationToken cancellationToken) | |
{ | |
throw new NotImplementedException(); | |
} | |
}]]></Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment