Archive

Posts Tagged ‘Code Providers’

MVC-specific CodeRush code declaration providers

September 21st, 2012 Comments off

There are three code generation providers specific to MVC. They allow you to declare MVC controllers, MVC actions and MVC views correspondingly:

  • Declare Controller
  • Declare Action
  • Declare View

Read more…

Code provider to format the String.Format call output

September 4th, 2012 Comments off

The String.Format call is the best approach for outputting information for the user to read. It replaces the format items in the specified template string with the string representation of the corresponding objects. The template string contains text that is desired in the final string and one or more format item placeholders, which will be replaced with other values passed as arguments to the String.Format call as either variable references or other literals.

Read more…

Code providers for working in two-dimensional space

September 4th, 2012 Comments off

There are two code providers that are useful when you have written the code to work in one dimension, but if you want to create a similar code to work in a two-dimensional space, here is an example:

Read more…

Implementing the IDisposable pattern using CodeRush

August 15th, 2012 4 comments

The IDisposable Pattern is used to release and close unmanaged resources such as files, streams, and handles as well as references to managed objects that use unmanaged resources, held by an instance of the class. For classes that require a resource cleanup, we recommended following the IDisposable pattern, which provides a standard and unambiguous pattern. The pattern has been designed to ensure reliable, predictable cleanup, and to prevent temporary resource leaks.

Read more…

Coding Helpers – Add Initialization

August 15th, 2012 Comments off

The Add Initialization code provider inserts an initialization of the selected field or auto-implemented property to each constructor of the active type. The code provider is useful when you want to initialize those objects with a different default value:

Read more…

Quick ways to add and remove a set/get property accessor with CodeRush

August 9th, 2012 Comments off

A property without a ‘set’ accessor is considered read-only:

CodeRush Add Setter code sample

Read more…

Coding Helpers – Reverse For Loop

August 9th, 2012 Comments off

When working with arrays and lists enumerating all of its items we usually create a for loop statement as follows:

CodeRush Reverse For Loop code sample

Read more…

Declare Attribute CodeRush code provider

June 1st, 2012 2 comments

Attributes provide a powerful method of associating declarative information by decorating elements of the code, such as types, methods, properties, parameters and assemblies. Once an attribute is associated with a program entity, it can be queried at run time and used in various cases, for example, associating a help document with program entities (via the Help attribute), or marking an item as out of date (via the Obsolete attribute).

Read more…