CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

Resharper 5 beta - Extension method refactoring

296 Views
Copy Code Show/Hide Line Numbers
   1:  foreach (var group in groups)
   2:                  {
   3:                      if (group.AllowsPermission(permissionType))
   4:                      {
   5:                          cache.Put(cacheKey, new List<bool> {true});
   6:                          return true;
   7:                      }
   8:                  }
   9:   
  10:   
  11:  //refactors to
  12:   
  13:  if (Enumerable.Any(groups, group => group.AllowsPermission(permissionType)))
  14:                  {
  15:                      cache.Put(cacheKey, new List<bool> {true});
  16:                      return true;
  17:                  }
  18:   
  19:  //could (should) refactor to
  20:   
  21:  if (groups.Any(group => group.AllowsPermission(permissionType)))
  22:                  {
  23:                      cache.Put(cacheKey, new List<bool> {true});
  24:                      return true;
  25:                  }
by Steven Burman
  December 23, 2009 @ 4:48pm
Tags:

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate