visual studio代码片段

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>apifunc</Title>
			<Shortcut>apifunc</Shortcut>
			<Description>webApi方法的代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>类型</ToolTip>
					<Default>string</Default>
				</Literal>
				<Literal>
					<ID>methodname</ID>
					<ToolTip>方法名</ToolTip>
					<Default>MyMethod</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[public async Task<ActionResult<IEnumerable<$type$>>> $methodname$ ()
	{
		$end$
	}]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>asynccmdmvvm</Title>
			<Shortcut>asynccmdmvvm</Shortcut>
			<Description>异步命令和支持命令的MVVM代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>命令类型</ToolTip>
					<Default>ICommand</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>命令名</ToolTip>
					<Default>AsyncCmd</Default>
				</Literal>
				<Literal>
					<ID>field</ID>
					<ToolTip>支持此命令的变量</ToolTip>
					<Default>_asyncCmd</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[private $type$ $field$;

	public $type$ $property$
	{
	get
        {
        	$field$ ??= new AsyncRelayCommand(async () =>
            {
                await Task.Delay(1000);
            });
            return $field$;
        }
	}
	$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>cmdavaloniaui</Title>
			<Shortcut>cmdavaloniaui</Shortcut>
			<Description>Avalonia UI命令和支持命令的MVVM代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>参数类型</ToolTip>
					<Default>Object</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>命令名</ToolTip>
					<Default>Cmd</Default>
				</Literal>
				<Literal>
					<ID>field</ID>
					<ToolTip>支持此命令的变量</ToolTip>
					<Default>_cmd</Default>
				</Literal>
				<Literal>
					<ID>argument</ID>
					<ToolTip>参数名称</ToolTip>
					<Default>arg</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[private ICommand $field$;

	public ICommand $property$
	{
		get
		{
            $field$ ??= ReactiveCommand.Create<$type$>($argument$ =>
            {
                //TODO
            });
            return $field$;
        }
	}
	$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>cmdmvvm</Title>
			<Shortcut>cmdmvvm</Shortcut>
			<Description>命令和支持命令的MVVM代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>命令类型</ToolTip>
					<Default>ICommand</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>命令名</ToolTip>
					<Default>Cmd</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[private ICommand $field$;

	public ICommand $property$
	{
		get
		{
            $field$ ??= new RelayCommand(() =>
            {
                //TODO
            });
            return $field$;
        }
	}
	$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>cr</Title>
			<Shortcut>cr</Shortcut>
			<Description>Console.ReadLine 的代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal Editable="false">
					<ID>SystemConsole</ID>
					<Function>SimpleTypeName(global::System.Console)</Function>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[$SystemConsole$.ReadLine($end$);]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>dc</Title>
			<Shortcut>dc</Shortcut>
			<Description>CommandProperty的代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal Editable="false">
					<ID>classname</ID>
					<ToolTip>类名</ToolTip>
					<Function>ClassName()</Function>
					<Default>ClassNamePlaceholder</Default>
				</Literal>
				<Literal>
					<ID>type</ID>
					<ToolTip>属性类型</ToolTip>
					<Default>ICommand</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>属性名</ToolTip>
					<Default>MyCommand</Default>
				</Literal>
				<Literal>
					<ID>wpdp</ID>
					<ToolTip>依赖属性名</ToolTip>
					<Default>MyCommandProperty</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[ public $type$ $property$
        {
            get => ($type$)GetValue($wpdp$);
            set => SetValue($wpdp$, value);
        }

        public static readonly DependencyProperty $wpdp$
            = DependencyProperty.Register(nameof($property$), typeof($type$), typeof($classname$), new PropertyMetadata(default($type$)));]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>dp</Title>
			<Shortcut>dp</Shortcut>
			<Description>DependencyProperty的代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal Editable="false">
					<ID>classname</ID>
					<ToolTip>类名</ToolTip>
					<Function>ClassName()</Function>
					<Default>ClassNamePlaceholder</Default>
				</Literal>
				<Literal>
					<ID>type</ID>
					<ToolTip>属性类型</ToolTip>
					<Default>int</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>属性名</ToolTip>
					<Default>MyProperty</Default>
				</Literal>
				<Literal>
					<ID>wpdp</ID>
					<ToolTip>依赖属性名</ToolTip>
					<Default>MyDependencyProperty</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[ public $type$ $property$
        {
            get => ($type$)GetValue($wpdp$);
            set => SetValue($wpdp$, value);
        }

        public static readonly DependencyProperty $wpdp$
            = DependencyProperty.Register(nameof($property$), typeof($type$), typeof($classname$), new PropertyMetadata(default($type$)));$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>field</Title>
			<Shortcut>field</Shortcut>
			<Description>只读字段的代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>类型</ToolTip>
					<Default>string</Default>
				</Literal>
				<Literal>
					<ID>fieldname</ID>
					<ToolTip>只读字段名</ToolTip>
					<Default>_myField</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[private readonly $type$ $fieldname$;]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>privatemethod</Title>
			<Shortcut>pri</Shortcut>
			<Description>private方法的代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal Editable="false">
					<ID>methodname</ID>
					<ToolTip>方法名</ToolTip>
					<Default>MethodName</Default>
				</Literal>
				<Literal>
					<ID>expression</ID>
					<ToolTip>异常类型</ToolTip>
					<Function>SimpleTypeName(global::System.Exception)</Function>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[private void $methodname$()
	{
		try 
	{	        
		$selected$
	}
	catch ($expression$)
	{
		throw;
	}
	}]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>propavaloniaui</Title>
			<Shortcut>propavaloniaui</Shortcut>
			<Description>Avalonia UI属性和支持字段的MVVM代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>属性类型</ToolTip>
					<Default>int</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>属性名</ToolTip>
					<Default>MyProperty</Default>
				</Literal>
				<Literal>
					<ID>field</ID>
					<ToolTip>支持此属性的变量</ToolTip>
					<Default>_myVar</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[private $type$ $field$;

	public $type$ $property$
	{
		get => $field$;
		set => this.RaiseAndSetIfChanged(ref $field$, value);
	}
	$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>propmvvm</Title>
			<Shortcut>propmvvm</Shortcut>
			<Description>属性和支持字段的MVVM代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>属性类型</ToolTip>
					<Default>int</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>属性名</ToolTip>
					<Default>MyProperty</Default>
				</Literal>
				<Literal>
					<ID>field</ID>
					<ToolTip>支持此属性的变量</ToolTip>
					<Default>_myVar</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[private $type$ $field$;

	public $type$ $property$
	{
		get => $field$;
		set => SetProperty(ref $field$, value);
	}
	$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>publicmethod</Title>
			<Shortcut>pub</Shortcut>
			<Description>public方法的代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal Editable="false">
					<ID>methodname</ID>
					<ToolTip>方法名</ToolTip>
					<Default>MethodName</Default>
				</Literal>
				<Literal>
					<ID>expression</ID>
					<ToolTip>异常类型</ToolTip>
					<Function>SimpleTypeName(global::System.Exception)</Function>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[public void $methodname$()
	{
		try 
	{	        
		$selected$
	}
	catch ($expression$)
	{
		throw;
	}
	}]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>#region class</Title>
			<Shortcut>reclass</Shortcut>
			<Description>#region 的代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
				<SnippetType>SurroundsWith</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Code Language="csharp"><![CDATA[#region Events
				//
				$selected$ $end$
			#endregion
			#region  Properties&Fileds
			//
			#region Comnands
			//
				$selected$ $end$
			#endregion
				$selected$ $end$
			#endregion
			#region Methods
			//
				$selected$ $end$
			#endregion
		]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>tw</Title>
			<Shortcut>tw</Shortcut>
			<Description>Trace.WriteLine 的代码片段</Description>
			<Author>wp</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Code Language="csharp"><![CDATA[Trace.WriteLine($end$);]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值