DCSIMG
Code snippet for control wrapping properties - Ran Wahle's blog

Ran Wahle's blog

Code snippet for control wrapping properties

Code snippet for control wrapping properties

Hello everyone.

many of us,  I’m sure, needed to wrap inner controls of a user\custom control 
with public properties. That’s in order to have their control encapsulated,
and to add some code flexibility (If the control is changing, all I need to do is
change the code of my property and the rest remains intact.

Therefore I’ve made a code snippet for myself that allow me to write these kind
of properties easily, and figured why not let everyone use it.

I hope you’ll find it useful.

 

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>Control Property</Title>
            <Shortcut>propctrl</Shortcut>
            <Description>Code snippet for property with get and set accessors 
      that wraps an inner control</Description>
            <Author>Ran Wahle</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>type</ID>
                    <ToolTip>Property type</ToolTip>
                    <Default>string</Default>
                </Literal>
                <Literal>
                    <ID>name</ID>
                    <Default>PropName</Default>
          <ToolTip>Property name</ToolTip>
                </Literal>
        <Literal>
          <ID>controlName</ID>
          <Default>ctrlName</Default>
          <ToolTip>Control Name</ToolTip>
        </Literal>
        <Literal>
          <ID>controlInnerProperty</ID>
          <Default>Text</Default>
          <ToolTip>Control Inner property</ToolTip>
        </Literal>
            </Declarations>
            <Code Language="csharp">
        <![CDATA[
        /// <summary>
        /// Put summary for $name$
        /// </summary>
        public $type$ $name$
        {
            get
            {
                return $controlName$.$controlInnerProperty$;
            }
            set
            {
                $controlName$.$controlInnerProperty$ = value;
            }
        }
]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>
kick it on DotNetKicks.com
Posted: Dec 29 2009, 03:46 PM by Ran Wahle | with 1 comment(s) |
תגים:, ,

Comments

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# December 31, 2009 8:27 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: