CodeIt.Right Takes Refactoring To The Next Level


Background I’m a big believer in using refactoring tools to help improve the quality of the code I right.  I just added another tool to my arsenal called CodeIt.Right from submain.  I can’t say for sure whether the other tools commonly used will somehow perform the refactoring I’m going to show, but I can say I really like how CodeIt.Right does it.  When I say it takes it to the next level, what I mean is it shows me things I know I should be doing (or in this case I’m fixing code that I got from someplace else.   As it turns out, the place I got it from was Microsoft’s samples for building Windows Store 8 apps.  If you want to find the original code, take a look at the WindowsBlogReader example to find the … Continue Reading

Simple Type Safe Coding in Microsoft’s C#

  I often like to show programming tips around simple things.  Over the years, I’ve found that it is easy to get Lazy and do cutting and pasting type coding, however for reliability and maintainability, it’s important to stick to the principle of less is more. Below is just a simple pattern I often use when doing something that requires processing over a set of images (or anything) multiple times. foreach (var rec in imageDetails) { const string imageTypeFull = "ImageTypeFull"; const string imageTypeThumb = "ImageTypeThumb"; foreach (var imageType in new List<string> {imageTypeFull, imageTypeThumb}) { var bytes = imageType == imageTypeFull ? … Continue Reading

Using LINQ ForEach To Populate Generic List in C# AND Enum to List

A C# trick I first had trouble wrapping my head around is using the LINQ ForEach operator to populate a list.  I was originally inspired by some source I found in the EXT.NET Icon building sample.   In addition to the ForEach lamda trick they included a very nice pattern for converting a c# Enum to a List.  So, let’s get right to the code.   enum Days { Sat = 1, Sun, Mon, Tue, Wed, Thu, Fri }; static void Main(string[] args) { List<string> daysOfWeekList = Enum.GetNames(typeof(Days)).ToList(); daysOfWeekList.ForEach(a => Console.WriteLine(a)); }   That’s it!   Just another two patterns of using c# which helps me live cleaner in c#! HTH’s. … Continue Reading

In C# Passing Delegate As Parameter, Then Executing on Return

I did not know that it is possible to have a delegate as a call to a method, then have that method actually execute that delegate at it’s convenience.  I’m busy converting a Xamarin conference application for the IPad and am wrangling getting it to show Silicon Valley Code Camp data rather than MWC (Mobile World Conference data). So, here is the method I ran into: var siteParser = new MWC.SAL.MWCSiteParser(); siteParser.GetConference (Constants.ConferenceDataUrl, () => { var c = siteParser.ConferenceData; if (c == null) { … Continue Reading


Get every new post delivered to your Inbox

Join other followers: