Recommended Reading

MethodStatic

Description

Generates a static public method with the given type and name.

Usage

[type] <name> ms

Example

string foo ms

Source Code

<?xml version="1.0" encoding="utf-8"?>
<Commands xmlns="http://schemas.devprojects.net/AutoCode/v4.0">
  <Command name="MethodStatic" version="1.0">

    <CommandBehavior>
      <CommandLine shortcut="ms" />
      <ActiveDocument extensions=".cs"/>
    </CommandBehavior>

    <CommandInfo>
      <LanguageCategory>CSharp</LanguageCategory>
      <Category>Members/Methods</Category>
      <Usage>
        <![CDATA[[type] <name> ms]]>
      </Usage>
      <Example>string foo ms</Example>
      <Description>Generates a static public method with the given type and name.</Description>
      <Author>DevProjects</Author>
      <HelpUrl>http://help.devprojects.net/gallery/command/methodstatic</HelpUrl>
    </CommandInfo>

    <CommandCode language="csharp">

      <BeforeExecute>
        <![CDATA[
        if( Arguments.Length < 1)
        {
          CommandHelper.InvalidArguments("Please, specify the type and name (or just the name) of the method.");
          return false;
        }
        if( Arguments.Length < 2)
        {
          Arguments = new string[] { "void", Arguments[0] };
        }
        return true;
        ]]>
      </BeforeExecute>

      <Codes>

        <Code id="Code1">
          <![CDATA[static public <#=args[0]#> <#=ToPascalCase(args[1])#>(]]>
        </Code>

        <Code id="Code2">
          <![CDATA[) 
        {
        }]]>
        </Code>

      </Codes>

      <!-- Formats the rendered code; from the beginning of 'Code1' until the end of 'Code2' -->
      <SmartFormat>
        <Start codeElement="Code1" codePoint="StartOfElement" />
        <End codeElement="Code2" codePoint="EndOfElement" />
      </SmartFormat>

      <!-- Positions cursor at the end of 'Code1', inside the parenthesis -->
      <Selection codeElement="Code1" codePoint="EndOfElement" />

    </CommandCode>
      <Signature><![CDATA[
      wp7Jn7ZCwACiKWLn1AZ/17ys+gTKn+9fgHSFcAE9VmPuOweO6ZhEMSCil
      D6LWhmiZ/wzZkzPKgGd22vHsV/4tgqCEXS4HNOVM5+QfcDXOvpCUQgkqJ
      WF7L3+oac8L6r0wb4yra7p5c1Z9FSN8qA3x5Uo/He3JGz+dleKZD+tu04=
    ]]></Signature>

</Command>
</Commands>