Advertisement
altair

Moje snippety

Mar 22nd, 2011
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 9.30 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.     <CodeSnippet Format="1.0.0">
  4.         <Header>
  5.             <Title>Check if argument is null</Title>
  6.             <Shortcut>can</Shortcut>
  7.             <Description>
  8.             </Description>
  9.             <Author>Michal A. Valasek</Author>
  10.         </Header>
  11.         <Snippet>
  12.             <Declarations>
  13.                 <Literal Editable="true">
  14.                     <ID>ArgumentName</ID>
  15.                     <ToolTip>
  16.                     </ToolTip>
  17.                     <Default>arg</Default>
  18.                     <Function>
  19.                     </Function>
  20.                 </Literal>
  21.             </Declarations>
  22.             <Code Language="csharp">
  23.                 <![CDATA[if($ArgumentName$ == null) throw new ArgumentNullException("$ArgumentName$");
  24. ]]>
  25.             </Code>
  26.         </Snippet>
  27.     </CodeSnippet>
  28.     <CodeSnippet Format="1.0.0">
  29.         <Header>
  30.             <Title>Check if argument is empty string</Title>
  31.             <Shortcut>cae</Shortcut>
  32.             <Description>
  33.             </Description>
  34.             <Author>Michal A. Valasek</Author>
  35.         </Header>
  36.         <Snippet>
  37.             <Declarations>
  38.                 <Literal Editable="true">
  39.                     <ID>ArgumentName</ID>
  40.                     <ToolTip>
  41.                     </ToolTip>
  42.                     <Default>arg</Default>
  43.                     <Function>
  44.                     </Function>
  45.                 </Literal>
  46.             </Declarations>
  47.             <Code Language="csharp"><![CDATA[if(string.IsNullOrEmpty($ArgumentName$)) throw new ArgumentException("Value cannot be null or empty string.", "$ArgumentName$");]]></Code>
  48.         </Snippet>
  49.     </CodeSnippet>
  50.     <CodeSnippet Format="1.0.0">
  51.         <Header>
  52.             <Title>Check if argument is null or empty string</Title>
  53.             <Shortcut>cane</Shortcut>
  54.             <Description>
  55.             </Description>
  56.             <Author>Michal A. Valasek</Author>
  57.         </Header>
  58.         <Snippet>
  59.             <Declarations>
  60.                 <Literal Editable="true">
  61.                     <ID>ArgumentName</ID>
  62.                     <ToolTip>
  63.                     </ToolTip>
  64.                     <Default>arg</Default>
  65.                     <Function>
  66.                     </Function>
  67.                 </Literal>
  68.             </Declarations>
  69.             <Code Language="csharp">
  70.                 <![CDATA[if($ArgumentName$ == null) throw new ArgumentNullException("$ArgumentName$");
  71. if(string.IsNullOrEmpty($ArgumentName$)) throw new ArgumentException("Value cannot be null or empty string.", "$ArgumentName$");
  72. ]]>
  73.             </Code>
  74.         </Snippet>
  75.     </CodeSnippet>
  76.     <CodeSnippet Format="1.0.0">
  77.         <Header>
  78.             <Title>Check if argument is null, empty or whitespace string</Title>
  79.             <Shortcut>canew</Shortcut>
  80.             <Description>
  81.             </Description>
  82.             <Author>Michal A. Valasek</Author>
  83.         </Header>
  84.         <Snippet>
  85.             <Declarations>
  86.                 <Literal Editable="true">
  87.                     <ID>ArgumentName</ID>
  88.                     <ToolTip>
  89.                     </ToolTip>
  90.                     <Default>arg</Default>
  91.                     <Function>
  92.                     </Function>
  93.                 </Literal>
  94.             </Declarations>
  95.             <Code Language="csharp">
  96.                 <![CDATA[if($ArgumentName$ == null) throw new ArgumentNullException("$ArgumentName$");
  97. if(string.IsNullOrWhiteSpace($ArgumentName$)) throw new ArgumentException("Value cannot be empty or whitespace only string.", "$ArgumentName$");
  98. ]]>
  99.             </Code>
  100.         </Snippet>
  101.     </CodeSnippet>
  102.     <CodeSnippet Format="1.0.0">
  103.         <Header>
  104.             <Title>Response redirect</Title>
  105.             <Shortcut>rr</Shortcut>
  106.             <Description>Performs response redirect</Description>
  107.             <Author>Michal A. Valasek</Author>
  108.         </Header>
  109.         <Snippet>
  110.             <Declarations>
  111.                 <Literal Editable="true">
  112.                     <ID>Url</ID>
  113.                     <ToolTip>
  114.                     </ToolTip>
  115.                     <Default>Default.aspx</Default>
  116.                     <Function>
  117.                     </Function>
  118.                 </Literal>
  119.             </Declarations>
  120.             <Code Language="csharp"><![CDATA[Response.Redirect("$Url$");]]></Code>
  121.         </Snippet>
  122.     </CodeSnippet>
  123.     <CodeSnippet Format="1.0.0">
  124.         <Header>
  125.             <Title>If not is valid, return</Title>
  126.             <Shortcut>invr</Shortcut>
  127.             <Description>Skips processing on validation errors</Description>
  128.             <Author>Michal A. Valasek</Author>
  129.         </Header>
  130.         <Snippet>
  131.             <Code Language="csharp"><![CDATA[if(!this.IsValid) return;$end$]]></Code>
  132.         </Snippet>
  133.     </CodeSnippet>
  134.     <CodeSnippet Format="1.0.0">
  135.         <Header>
  136.             <Title>Create configuration property</Title>
  137.             <Shortcut>cprop</Shortcut>
  138.             <Description>
  139.             </Description>
  140.             <Author>Michal A. Valasek</Author>
  141.         </Header>
  142.         <Snippet>
  143.             <Declarations>
  144.                 <Literal Editable="true">
  145.                     <ID>Attribute</ID>
  146.                     <ToolTip>
  147.                     </ToolTip>
  148.                     <Default>name</Default>
  149.                     <Function>
  150.                     </Function>
  151.                 </Literal>
  152.                 <Literal Editable="true">
  153.                     <ID>Property</ID>
  154.                     <ToolTip>
  155.                     </ToolTip>
  156.                     <Default>Name</Default>
  157.                     <Function>
  158.                     </Function>
  159.                 </Literal>
  160.                 <Literal Editable="true">
  161.                     <ID>Required</ID>
  162.                     <ToolTip>
  163.                     </ToolTip>
  164.                     <Default>false</Default>
  165.                     <Function>
  166.                     </Function>
  167.                 </Literal>
  168.                 <Literal Editable="true">
  169.                     <ID>Default</ID>
  170.                     <ToolTip>
  171.                     </ToolTip>
  172.                     <Default>""</Default>
  173.                     <Function>
  174.                     </Function>
  175.                 </Literal>
  176.                 <Object Editable="true">
  177.                     <ID>Type</ID>
  178.                     <ToolTip>
  179.                     </ToolTip>
  180.                     <Default>string</Default>
  181.                     <Function>
  182.                     </Function>
  183.                 </Object>
  184.             </Declarations>
  185.             <Code Language="csharp">
  186.                 <![CDATA[[ConfigurationProperty("$Attribute$", IsRequired = $Required$, DefaultValue = $Default$)]
  187. public $Type$  $Property$ {
  188.     get { return ($Type$)this["$Attribute$"]; }
  189.     set { this["$Attribute$"] = value; }
  190. }]]>
  191.             </Code>
  192.         </Snippet>
  193.     </CodeSnippet>
  194.     <CodeSnippet Format="1.0.0">
  195.         <Header>
  196.             <Title>Create configuration element</Title>
  197.             <Shortcut>celm</Shortcut>
  198.             <Description>
  199.             </Description>
  200.             <Author>Michal A. Valášek</Author>
  201.         </Header>
  202.         <Snippet>
  203.             <Declarations>
  204.                 <Literal Editable="true">
  205.                     <ID>ElementName</ID>
  206.                     <ToolTip>
  207.                     </ToolTip>
  208.                     <Default>name</Default>
  209.                     <Function>
  210.                     </Function>
  211.                 </Literal>
  212.                 <Literal Editable="true">
  213.                     <ID>PropertyName</ID>
  214.                     <ToolTip>
  215.                     </ToolTip>
  216.                     <Default>Name</Default>
  217.                     <Function>
  218.                     </Function>
  219.                 </Literal>
  220.             </Declarations>
  221.             <Code Language="csharp">
  222.                 <![CDATA[[ConfigurationProperty("$ElementName$")]
  223. public $PropertyName$Element $PropertyName$ {
  224.     get { return this["$ElementName$"] as $PropertyName$Element; }
  225.     set { this["$ElementName$"] = value; }
  226. }]]>
  227.             </Code>
  228.         </Snippet>
  229.     </CodeSnippet>
  230.     <CodeSnippet Format="1.0.0">
  231.         <Header>
  232.             <Title>Create web control property</Title>
  233.             <Shortcut>wprop</Shortcut>
  234.             <Description>
  235.             </Description>
  236.             <Author>Michal A. Valasek</Author>
  237.         </Header>
  238.         <Snippet>
  239.             <Declarations>
  240.                 <Literal Editable="true">
  241.                     <ID>Property</ID>
  242.                     <ToolTip>
  243.                     </ToolTip>
  244.                     <Default>Name</Default>
  245.                     <Function>
  246.                     </Function>
  247.                 </Literal>
  248.                 <Object Editable="true">
  249.                     <ID>Type</ID>
  250.                     <ToolTip>
  251.                     </ToolTip>
  252.                     <Default>string</Default>
  253.                     <Function>
  254.                     </Function>
  255.                 </Object>
  256.             </Declarations>
  257.             <Code Language="csharp">
  258.                 <![CDATA[public $Type$  $Property$ {
  259.     get { return ($Type$)this.ViewState["$Property$"]; }
  260.     set { this.ViewState["$Property$"] = value; }
  261. }]]>
  262.             </Code>
  263.         </Snippet>
  264.     </CodeSnippet>
  265. </CodeSnippets>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement