Recommended Reading

MethodProtected

Description

Generates a protected method with the given type and name.

Usage

[type] <name> mpr

Example

string foo mpr

Source Code

<?xml version="1.0" encoding="utf-8"?>
<Commands xmlns="http://schemas.devprojects.net/AutoCode/v4.0">
  <Command name="MethodProtected" version="1.0">
    
    <CommandBehavior>
      <CommandLine shortcut="mpr" />
      <ActiveDocument extensions=".cs"/>
    </CommandBehavior>

    <CommandInfo>
      <LanguageCategory>CSharp</LanguageCategory>
      <Category>Members/Methods</Category>
      <Usage>
        <![CDATA[[type] <name> mpr]]>
      </Usage>
      <Example>string foo mpr</Example>
      <Description>Generates a protected method with the given type and name.</Description>
      <Author>DevProjects</Author>
      <HelpUrl>http://help.devprojects.net/gallery/command/methodprotected</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[protected <#=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[
      EOFMR4kXT5mOaQzbnhA3KeW79sH+zrasVvymoCq3OolVNFg8KTG/3FX4n
      7dT41LMS0XdnwBjU4xhKrZSdaeCwO38mpP95+zLSHW4K9I2N/2A3AkLzy
      dZWNxMTOqtZWUzqbyVe6kD1b7FqWgtxukZTpUPkDhbOu0tNETMmEv/zRs=
    ]]></Signature>

</Command>
</Commands>