where can I download the snippets for Visual Studio, the likes pf pmvx, cmvx and others? I though those would be available on the github projects, but can't find them...
I've already created my own. Please remember that these are ReSharper's template.
mvxcom -> for Command
#region $region$ command
private MvxCommand _$NAME$Command;
public ICommand $PNAME$Command
{
get
{
_$NAME$Command = _$NAME$Command ?? new MvxCommand(Do$PNAME$Command);
return _$NAME$Command;
}
}
private void Do$PNAME$Command()
{
$END$
}
#endregion
mvxprop -> for Properties
#region $region$
private $TYPE$ _$NAME$;
public $TYPE$ $PNAME$
{
get { return _$NAME$; }
set { _$NAME$ = value; RaisePropertyChanged(() => $PNAME$); }
}
#endregion
$END$
mvxset -> Binding Set
var set = this.CreateBindingSet<$VIEW$, $VIEW$Model>();
set.Bind($ELEMENT$).To(vm => vm$END$);
set.Apply();
You can add them to your ReSharper using ReSharper>Template Explorer>Live Templates>New Template.
Please feel free to change them however you desire.
And here's the native VS version of the snippets based on Aboo's answer above.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>MvvMCross Property</Title>
<Description>Insert a property block with a backing field and property change notification</Description>
<Shortcut>mvxprop</Shortcut>
<Author>Andrew Coates (based on Aboo's SO ReSharper Answer)</Author>
<HelpUrl>https://mcmap.net/q/964929/-mvvmcross-code-snippets-for-visual-studio</HelpUrl>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>backingfield</ID>
<ToolTip></ToolTip>
<Default>propertyName</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip></ToolTip>
<Default>PropertyName</Default>
</Literal>
<Literal>
<ID>propertyType</ID>
<ToolTip></ToolTip>
<Default>int</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[private $propertyType$ $backingfield$;
public $propertyType$ $property$
{
get { return $backingfield$; }
set { if($backingfield$ == value) return; $backingfield$ = value; RaisePropertyChanged(() => $property$); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
<CodeSnippet Format="1.0.0">
<Header>
<Title>MvvMCross Command</Title>
<Description>Insert a Command declaration for an MvvMCross View Model</Description>
<Shortcut>mvxcom</Shortcut>
<Author>Andrew Coates (based on Aboo's SO ReSharper Answer)</Author>
<HelpUrl>https://mcmap.net/q/964929/-mvvmcross-code-snippets-for-visual-studio</HelpUrl>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>backingfield</ID>
<ToolTip></ToolTip>
<Default>commandName</Default>
</Literal>
<Literal>
<ID>Name</ID>
<ToolTip></ToolTip>
<Default>CommandName</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[private MvxCommand $backingfield$Command;
public MvxCommand $Name$Command
{
get
{
$backingfield$Command = $backingfield$Command ?? new MvxCommand(Do$Name$Command);
return $backingfield$Command;
}
}
private void Do$Name$Command()
{
$end$
}
]]>
</Code>
</Snippet>
</CodeSnippet>
<CodeSnippet Format="1.0.0">
<Header>
<Title>MvvMCross Binding Set</Title>
<Description>Create a binding set and bind an element</Description>
<Shortcut>mvxset</Shortcut>
<Author>Andrew Coates (based on Aboo's SO ReSharper Answer)</Author>
<HelpUrl>https://mcmap.net/q/964929/-mvvmcross-code-snippets-for-visual-studio</HelpUrl>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>viewName</ID>
<ToolTip></ToolTip>
<Default>viewName</Default>
</Literal>
<Literal>
<ID>element</ID>
<ToolTip></ToolTip>
<Default>element</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[var set = this.CreateBindingSet<$viewName$View, $viewName$ViewModel>();
set.Bind($element$).To(vm => vm$end$);
set.Apply();
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
If I'm correct in my presumption, you're referring to the shortcuts that Stuart uses in his demos for MvvmCross. These are snippets of code that he has written and assigned to shortcuts using ReSharper and are not publicly available, though if you asked nicely they can be exported and shared. Of course you could always make your own 'Live Template' using this tutorial
I modified @Coasty's answer to include an async command adapted from https://mcmap.net/q/491473/-how-can-i-use-async-in-an-mvvmcross-view-model and changed the shortcuts so they no longer collide with the mvx namespaces.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>MvvmCross Property</Title>
<Description>Insert a property block with a backing field and property change notification</Description>
<Shortcut>mvvmcrossprop</Shortcut>
<Author>Andrew Coates (based on Aboo's SO ReSharper Answer)</Author>
<HelpUrl>https://mcmap.net/q/964929/-mvvmcross-code-snippets-for-visual-studio</HelpUrl>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>backingfield</ID>
<ToolTip></ToolTip>
<Default>propertyName</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip></ToolTip>
<Default>PropertyName</Default>
</Literal>
<Literal>
<ID>propertyType</ID>
<ToolTip></ToolTip>
<Default>int</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[private $propertyType$ $backingfield$;
public $propertyType$ $property$
{
get { return $backingfield$; }
set { $backingfield$ = value; RaisePropertyChanged(() => $property$); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
<CodeSnippet Format="1.0.0">
<Header>
<Title>MvvmCross Command</Title>
<Description>Insert a Command declaration for an MvvmCross View Model</Description>
<Shortcut>mvvmcrosscom</Shortcut>
<Author>Andrew Coates (based on Aboo's SO ReSharper Answer)</Author>
<HelpUrl>https://mcmap.net/q/964929/-mvvmcross-code-snippets-for-visual-studio</HelpUrl>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>backingfield</ID>
<ToolTip></ToolTip>
<Default>commandName</Default>
</Literal>
<Literal>
<ID>Name</ID>
<ToolTip></ToolTip>
<Default>CommandName</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[private MvxCommand $backingfield$Command;
public MvxCommand $Name$Command
{
get
{
$backingfield$ = $backingfield$ ?? new MvxCommand(Do$Name$);
return $backingfield$;
}
}
private void Do$Name$()
{
$end$
}
]]>
</Code>
</Snippet>
</CodeSnippet>
<CodeSnippet Format="1.0.0">
<Header>
<Title>MvvmCross Async Command</Title>
<Description>Insert an Async Command declaration for an MvvmCross View Model</Description>
<Shortcut>mvvmcrossacom</Shortcut>
<Author>Benjamin Hysell (based on Andrew Coates Command Answer)</Author>
<HelpUrl>https://mcmap.net/q/964929/-mvvmcross-code-snippets-for-visual-studio</HelpUrl>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>backingfield</ID>
<ToolTip></ToolTip>
<Default>commandName</Default>
</Literal>
<Literal>
<ID>Name</ID>
<ToolTip></ToolTip>
<Default>CommandName</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[private MvxCommand $backingfield$Command;
public MvxCommand $Name$Command
{
get
{
$backingfield$ = $backingfield$ ?? new MvxCommand(async () => await Do$Name$());
return $backingfield$;
}
}
private async Task Do$Name$()
{
$end$
}
]]>
</Code>
</Snippet>
</CodeSnippet>
<CodeSnippet Format="1.0.0">
<Header>
<Title>MvvmCross Binding Set</Title>
<Description>Create a binding set and bind an element</Description>
<Shortcut>mvvmcrossset</Shortcut>
<Author>Andrew Coates (based on Aboo's SO ReSharper Answer)</Author>
<HelpUrl>https://mcmap.net/q/964929/-mvvmcross-code-snippets-for-visual-studio</HelpUrl>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>viewName</ID>
<ToolTip></ToolTip>
<Default>viewName</Default>
</Literal>
<Literal>
<ID>element</ID>
<ToolTip></ToolTip>
<Default>element</Default>
</Literal>
</Declarations>
<Code Language="CSharp">
<![CDATA[var set = this.CreateBindingSet<$viewName$View, $viewName$ViewModel>();
set.Bind($element$).To(vm => vm$end$);
set.Apply();
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
© 2022 - 2024 — McMap. All rights reserved.