Created
January 20, 2012 20:02
-
-
Save qwertie/1649289 to your computer and use it in GitHub Desktop.
C# code snippets for using UpdateControls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>dep</Title> | |
<Shortcut>dep</Shortcut> | |
<Description>Code snippet to help you make properties based on 'Dependent<T>', an Update Controls class that represents a value computed based on one or more Independents. Note: in most cases you should just write a normal property instead of using Dependent<T>. Dependent<T> is useful to cache the result of a computation when the value of the property is expensive to compute.</Description> | |
<Author>David Piepgrass</Author> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>type</ID> | |
<Default>string</Default> | |
<ToolTip>Data type</ToolTip> | |
</Literal> | |
<Literal> | |
<ID>name</ID> | |
<Default>CalculatedProperty</Default> | |
<ToolTip>A name for this computed property</ToolTip> | |
</Literal> | |
<Literal> | |
<ID>expr</ID> | |
<Default>TODO</Default> | |
<ToolTip>Write an expression here to compute the value of the Dependent</ToolTip> | |
</Literal> | |
</Declarations> | |
<Code Language="csharp"><![CDATA[Dependent<$type$> _$name$; | |
public $type$ $name$ | |
{ | |
get { | |
if (_$name$ == null) | |
_$name$ = new Dependent<$type$>("$name$", | |
() => $expr$); | |
return _$name$.Value; | |
} | |
}]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>depList</Title> | |
<Shortcut>depList</Shortcut> | |
<Description>Code snippet for 'DependentList<T>', which is used to compute a list of values based on a set of other values that utilize Independent, Dependent or other classes in Update Controls.</Description> | |
<Author>David Piepgrass</Author> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>type</ID> | |
<Default>string</Default> | |
<ToolTip>Data type of each element</ToolTip> | |
</Literal> | |
<Literal> | |
<ID>name</ID> | |
<Default>List</Default> | |
<ToolTip>Property Name</ToolTip> | |
</Literal> | |
<Literal> | |
<ID>expr</ID> | |
<Default>return TODO;</Default> | |
<ToolTip>Write a LINQ query or other code to compute the list of items as IEnumerable<T%gt;.</ToolTip> | |
</Literal> | |
</Declarations> | |
<Code Language="csharp"><![CDATA[DependentList<$type$> _$name$; | |
public DependentList<$type$> $name$ | |
{ | |
get { | |
if (_$name$ == null) | |
_$name$ = new DependentList<$type$>("$name$", () => { | |
$expr$ | |
}); | |
return _$name$; | |
} | |
}]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>ind</Title> | |
<Shortcut>ind</Shortcut> | |
<Description>Code snippet for 'Independent<T>'</Description> | |
<Author>David Piepgrass</Author> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>type</ID> | |
<Default>string</Default> | |
<ToolTip>Data type</ToolTip> | |
</Literal> | |
<Literal> | |
<ID>name</ID> | |
<Default>Name</Default> | |
<ToolTip>Property Name</ToolTip> | |
</Literal> | |
</Declarations> | |
<Code Language="csharp"><![CDATA[Independent<$type$> _$name$ = new Independent<$type$>("$name$", default($type$)); | |
public $type$ $name$ | |
{ | |
get { return _$name$.Value; } | |
set { _$name$.Value = value; } | |
}]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>indList</Title> | |
<Shortcut>indList</Shortcut> | |
<Description>Code snippet for 'IndependentList<T>'</Description> | |
<Author>David Piepgrass</Author> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>type</ID> | |
<Default>string</Default> | |
<ToolTip>Data type of each element</ToolTip> | |
</Literal> | |
<Literal> | |
<ID>name</ID> | |
<Default>List</Default> | |
<ToolTip>Property Name</ToolTip> | |
</Literal> | |
</Declarations> | |
<Code Language="csharp"><![CDATA[IndependentList<$type$> _$name$ = new IndependentList<$type$>(); | |
public IList<$type$> $name$ | |
{ | |
get { return _$name$; } | |
}]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment