Code snippet for control wrapping properties

29 בדצמבר 2009

tags: , ,
no comments

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

Add comment
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. (*) שדות חובה מסומנים

תגי HTML מותרים: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>