# Wednesday, August 26, 2009

Tools that make a developers life easier

Last night at the BAND (www.bangordevelopers.com) meeting we all did 10 minute presentations on the tool(s) we love as developers.

On my list were: Total Commander, LinqPad, Microsoft Office (codegen with Excel rules :-)), VMWare & VirtualPC, Live Mesh. Also on the list should have been Reflector.

Total Commander

Great tool for FTP-ing files and comparing a local folder hierarchy to the hierarchy on the ftp-server. Also much more reliable in FTP-ing large amounts of files than Windows Explorer.
image

See: www.ghisler.com

LinqPad

A must have for people using LINQ to SQL and Entity Framwork. Helps a lot with figuring out what the exact SQL statement is that get generated from your LINQ statement.
image
See: www.linqpad.net

VMWare Converter, VMWare Workstation and VirtualPC

These tools are invaluable in creating clean testing environments and separating multiple development environments on a single machine. VMWare converter allows you to grab a physical harddrive and convert it into a virtual machine. Very useful for Windows 7 migration scenarios!
See: www.vmware.com, www.microsoft.com/virtualpc

Live Mesh

Is only in beta, but already an invaluable tool for remote desktop connections across firewalls and synchronizing files across (virtual) machines.
See: www.mesh.com

Reflector

.NET Reflector is a tool any serious .NET developer cannot do without. View sources of any .NET library you use in order to track internal workings. Love it!
See: http://www.red-gate.com/products/reflector/

#    Comments [0] |
# Thursday, August 20, 2009

LINQ to Outlook

VSTO offers a number of classes to access Outlook information, but these classes do not implement IEnumerable<T> and are therefore not useable in a LINQ expression.

I wanted to be able to search for appointments using LINQ and write code that looks like this:

var appointments = new Appointments();

var selectedAppointments = from appointment in appointments
                           where appointment.Start <= end    // end is parameter
                           && appointment.End >= start       // start is parameter
                           && appointment.Categories.Contains("Billable")
                           orderby appointment.Start
                           select appointment;

To do this I converted the Items collection in an Outlook Folder to an IEnumerable<Outlook._AppointmentItem>.
The code for the Appointments class looks like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace Develop_One.OBiOne
{
    /// <summary>
    /// Class to wrap a collection of Outlook.Items as an IEnumerable of Outlook._AppointmentItem.
    /// Doing this allows you to write LINQ queries against the Appointments.
    /// </summary>
    internal class Appointments : IEnumerable<Outlook._AppointmentItem>
    {
        private Outlook.Items _items;

        /// <summary>
        /// Default constructor will use the items in the default Calendar folder to initialize items collection.
        /// </summary>
        internal Appointments()
        {
            var app = new Outlook.ApplicationClass();
            var cal = app.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
            _items = cal.Items;
        }


        #region IEnumerable<_AppointmentItem> Members

        public IEnumerator<Outlook._AppointmentItem> GetEnumerator()
        {
            // use the private AppointmentsEnumerator.
            return new AppointmentsEnumerator(this._items);
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }

        #endregion

        private class AppointmentsEnumerator : IEnumerator<Outlook._AppointmentItem>
        {
            private System.Collections.IEnumerator _items;

            internal AppointmentsEnumerator(Outlook.Items items)
            {
                _items = items.GetEnumerator();
            }


            #region IEnumerator<_AppointmentItem> Members

            public Outlook._AppointmentItem Current
            {
                get
                {
                    return (Outlook._AppointmentItem)_items.Current;
                }
            }

            #endregion

            #region IDisposable Members

            public void Dispose()
            {
                return;
            }

            #endregion

            #region IEnumerator Members

            object System.Collections.IEnumerator.Current
            {
                get
                {
                    return (Outlook._AppointmentItem)_items.Current;
                }
            }

            public bool MoveNext()
            {
                bool result = _items.MoveNext();
                while (_items.Current is Outlook._AppointmentItem == false && result == true)
                {
                    result = _items.MoveNext();
                }
                return result;
            }

            public void Reset()
            {
                _items.Reset();
            }

            #endregion
        }


    }
    

}
#    Comments [1] |

Paste from Visual Studio

I just came across a nice add-on for Windows Live Writer which allows you to paste colorized source from Visual Studio.

Download it here: http://gallery.live.com/liveItemDetail.aspx?li=d8835a5e-28da-4242-82eb-e1a006b083b9&bt=9&pl=8

#    Comments [0] |

Some useful DateTime extensions

I’m doing some work where a user can select data based on choice like “This week” and “Last month”. I wrote a bunch of extension methods that are pretty generic and may be useful for others.

Here is is:

public static class DateTimeExtensions
{
    /// <summary>
    /// Return the date that is the start of the week relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetStartOfWeek(this DateTime date)
    {
        DayOfWeek day = date.DayOfWeek;
        int days = day – CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
        DateTime start = date.AddDays(-days);
        return start.Date;
    }

    /// <summary>
    /// Return the date that is the start of the week relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetStartOfLastWeek(this DateTime date)
    {
        return date.GetStartOfWeek().AddDays(-7);
    }

    /// <summary>
    /// Return the date that is the end of the week relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetEndOfWeek(this DateTime date)
    {
        return date.GetStartOfWeek().AddDays(6);
    }

    /// <summary>
    /// Return the date that is the end of the week relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetEndOfLastWeek(this DateTime date)
    {
        return date.GetEndOfWeek().AddDays(-7);
    }

    /// <summary>
    /// Return the date that is the start of the month relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetStartOfMonth(this DateTime date)
    {
        return new DateTime(date.Year, date.Month, 1);
    }

    /// <summary>
    /// Return the date that is the start of previous month relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetStartOfLastMonth(this DateTime date)
    {
        return date.GetStartOfMonth().AddMonths(-1);
    }

    /// <summary>
    /// Return the date that is the end of the month relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetEndOfMonth(this DateTime date)
    {
        return new DateTime(date.Year, date.Month, date.GetDaysInMonth(), 23, 59, 59, 999);
    }

    /// <summary>
    /// Return the date that is the start of previous month relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetEndOfLastMonth(this DateTime date)
    {
        return date.GetStartOfLastMonth().GetEndOfMonth();
    }

    /// <summary>
    /// Returns the number of days in the month of the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static int GetDaysInMonth(this DateTime date)
    {
        return DateTime.DaysInMonth(date.Year, date.Month);
    }

    /// <summary>
    /// Return the first day of the year relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetStartOfYear(this DateTime date)
    {
        return new DateTime(date.Year, 1, 1);
    }

    /// <summary>
    /// Return the first day of the last year relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetStartOfLastYear(this DateTime date)
    {
        return new DateTime(date.Year - 1, 1, 1);
    }

    /// <summary>
    /// Return the last day of the year relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetEndOfYear(this DateTime date)
    {
        return new DateTime(date.Year, 12, 31, 23, 59, 59, 999);
    }

    /// <summary>
    /// Return the last day of the last year relative to the specified date.
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime GetEndOfLastYear(this DateTime date)
    {
        return new DateTime(date.Year - 1, 12, 31, 23, 59, 59, 999);
    }

}
#    Comments [7] |
# Tuesday, August 11, 2009

Zune HD now on pre-order

Zune HD The Zune-HD has gone on pre-order at Amazon.

Pre-Order Zune HD
#    Comments [0] |
# Thursday, August 06, 2009

Finished upgrade to Windows 7

windows 7 rev vI just finished upgrading my laptop (main machine) to Windows 7. I decided to go with an in place upgrade (after making a backup :-) ). I was a little worried that the Live Mesh beta might cause some problem, but… no problem. The system has been upgraded, Office 2007 is running, my Adobe AIR apps are running and Live Mesh is fully operational!

Congrats to Microsoft for an excellent upgrade experience!

image

#    Comments [0] |
# Wednesday, August 05, 2009

Microsoft Security Essentials

Just answered a question from a buddy about Windows Live One Care. The Live One Care product is being discontinued and will be replaced by Microsoft Security Essentials.
Microsoft Security Essentials is in beta right now. From what I understand Microsoft Security Essentials will be a free solution.
More info here: http://www.microsoft.com/security_essentials/.

From KezNews: “…the final product will be available only before end of 2009...”

#    Comments [0] |

Sponsored Tweets: The end of Twitter?

Just found out that there is now a company offering sponsored tweets (http://sponsoredtweets.com/). Will this be the end of Twitter, or will my virus scanner move these messages to my ‘spam tweets container’? Where do I get to opt-out? The site pretends to do ethical spamming (http://sponsoredtweets.com/ethics/) but offers no simple opt-out feature.

#    Comments [0] |
# Tuesday, August 04, 2009

Upgrading to Mac OS X Snow Leopard

Looks like Mac OS X Snow Leopard has gone into pre-order mode (look here). Too bad they don’t support my iMac anymore. The latest version(s) of iTunes won’t install on Mac OS X 10.3 and Snow Leopard won’t run on non-intel processors so my PowerPC G4 in my iMac is feeling more and more obsolete by the day.

Upgrade info:

Please note, that only Apple OS X Leopard users are eligible for the Snow Leopard upgrade. Tiger & earlier OS users will need to purchase either versions of the upgraded Mac Box Set. Also, Snow Leopard will only run on intel-based Mac computers.

More here.

#    Comments [0] |
# Thursday, July 30, 2009

ASP.NET 4.0 beta 1 playground

Just got an email from my favorite Internet provider (aren’t they the real cloud?) and they’re offering a ASP.NET 4.0 beta playground.

Quote:

“DiscountASP.NET, in partnership with Microsoft offers a FREE ASP.NET 4 hosting sandbox for MsDeploy RC1 and Visual Studio 2010 beta 1 users to experience 1-Click publishing.
The sandbox hosting program is a limited program offered as an open beta on a first come first serve basis. The account comes with 50 MB of disk space and 50 MB of SQL Server 2008 database space. The FREE ASP.NET hosting sandbox supports .NET Framework 4.0 beta 1, which is not a go-live version. This platform is only intended for testing and should not be used for production purposes.”

Go to www.discountasp.net for more info.

discountasp

#    Comments [0] |
# Wednesday, July 29, 2009

Windows 7 performs better than WindowsXP

Just came across an interesting article from GCN (Government Computer News), quote:

“It’s a victory that performance didn’t drop from XP, which we still consider one of the best operating systems out there. The fact that Windows 7 increased performance slightly across the board is pretty amazing…”

Read the full item here: http://gcn.com/Articles/2009/07/27/GCN-Lab-Windows-7-Performance-Tests.aspx

#    Comments [1] |

New Ergo keyboard

I received a door prize at last night’s BAND meeting: a Microsoft Natural Ergo Keyboard 4000.
I’ve got still got to get used to a little bit, but it feels good already :-)

#    Comments [1] |

Gartner predicts growth in software spending for 2010

After all the misery around the financial crisis is nice to see that Gartner is expecting a turnaround in 2010. Read more here: http://www.gartner.com/it/page.jsp?id=1096812.

#    Comments [0] |
# Monday, July 27, 2009

MDN - Augusta Developer Event, 27th of August 2009.

The MDN meeting on the 27th of August, 2009 will be an INETA sponsored event. INETA will make arrangements for Kathleen Dollard to be able to speak to our group. Kathleen is a great speaker and authority on the subject of code generation and software composability. We're very happy and lucky to have her come up and present two sessions at our meeting. A third session, also on code generation will be done by Mark Blomsma.

We'll start the meeting with free pizza at 12pm. With the first session starting at 12:30pm. We aim to finish around 5pm.

Code Generation
by Kathleen Dollard
Code generation is undergoing a renaissance as Microsoft jumps into the picture and converges with our increasing understanding of code generation. You’ll learn core code generation principles that transcend all code generation tools. Building on this you’ll get a dip into template languages seeing both T4 which is part of Visual Studio and VB9 XML literal templates in order to understand the strength of each approach. Once you understand how templates work, you’ll dive into metadata – the part of the system that uniquely describes the specific application your building. You’ll see two approaches to protecting handcrafted code on the .NET platform. And you’ll see how to hook generation into your development process. The overall process of application generation has not matured and is rapidly changing – this talk doesn’t promise silver bullets. Instead you’ll leave with a good understanding of the latest code generation techniques and how you can fit them into your unique development environment.

Introduction to Visual Studio T4
by Mark Blomsma
An introduction to a somewhat hidden feature in Visual Studio: Text Template Transformation Toolkit or T4 for short. You will learn about using T4 and the statement, expressions and declarations needed to succesfully use T4 in your software projects.

Composable Applications with MEF
by Kathleen Dollard
Decoupling portions of your application has tremendous payback during both development and maintenance. Your application becomes more testable and flexible and can more easily evolve to meet changing demands. Decoupling your application also allows a new level of partnership with external groups because you can safely incorporate their code in your application without recompiling or releasing source code – effectively creating ecosystems supported by your application. Over the years Microsoft has released several different provider models in different areas of the framework, libraries, and supporting tools. This year several teams at Microsoft moved toward consolidating these efforts with the Managed Extensibility Framework, or MEF. This tool differs from an IoC (Inversion of Control) container because focuses directly at application composability, extensibility, and discover. MEF supports Microsoft efforts like Visual Studio 2010, but it can also play a role in your current applications.

Kathleen Dollard is a consultant, author, trainer, and speaker. She’s been a Microsoft MVP for over ten years and has spoken about .NET in 28 states and 5 countries. She’s written dozens of articles including the “Ask Kathleen” column in Visual Studio Magazine. She also wrote “Code Generation in Microsoft .NET” (Apress). Her passion is helping programmers be smarter in how they develop by learning to better use .NET languages, libraries and platforms. She works with WPF, WF, as well as core technologies including System.AddIn. She’s currently creating template infrastructure for code generation using VB XML literals. After working on the problem of capturing business intent in metadata and test definitions for years, she’s working with industry improvements in these areas. She’s also working on full life cycle improvements, such as unit testing, better debugging and static analysis (FxCop). When not working, she enjoys woodworking, snowshoeing, and kayaking depending on the outdoor temperature.

Mark Blomsma is a consultant, author, trainer and speaker. He's been a Microsoft MVP for 6 years and has spoken at our meeting many time. He runs a consulting business up in Lincoln, ME.

Location
The event will be held at:
State of Maine Offices
Harlow Building
First floor conference room
18 Elkins Ave
Augusta

RSVP
Please register so we can accommodate accordingly and make sure we have enough pizza.
Register here: http://www.maine-devnet.org/Home/SignUpForEvent.aspx

#    Comments [1] |
# Thursday, July 23, 2009

DevelopMentor RSS Feed

I believe the URL has changed, so just in case you lost it… Keep track of blog posts from all the DevelopMentor instructors by subscribing to: http://browse.develop.com/bmsfeed/developmentor http://feeds.feedburner.com/DevelopmentorInstructors

Updated 08-19-2009: Feed is now available at: http://feeds.feedburner.com/DevelopmentorInstructors

#    Comments [0] |

Next Bangor Area .NET Developers (BAND) meeting is 07/28

Next Gig: Tuesday 07/28/2009 6:00 pm - 8:30 pm
Topic: Using Test-Driven Development to Get Done Fast
Presenter: Scott Bressette
Room: Kominsky Auditorium, Husson University, Bangor

Scott walks us through a real life situation to show how using Test-Driven Development gets the code done right the first time. He’ll discuss how understanding Agile concepts such as roles and motives will help you read “between the lines” of what clients are asking for and deliver what they really want. TDD can seem like an impediment to getting things done quickly, but Scott will show how he uses just a few simple techniques to code with both speed and confidence.
Scott is the Director of Development at Occupational Health Research in Skowhegan.

Register at http://www.bangordevelopers.com

#    Comments [0] |

Blog updated to dasBlog 2.3.9074.18820

I’ve just updated my blog to the latest version of dasBlog and enabled comments again. I picked a new theme (Mads Simple) to freshen things up a little and modified the theme to include a new service offered by DevelopMentor which allows you to browse my blog and that of my fellow DevelopMentor instructors in a great way. Check it out for yourself.

#    Comments [1] |

Windows 7 RTM

Just got this in the mail:
As you know, Microsoft® Windows 7 was Released to Manufacturing (RTM) this afternoon, July 22, 2009. We are excited to be releasing what we consider our best OS to date and we couldn’t have done it without you, our Technical Beta Testers!
With the announcement of RTM, the beta program is officially closed.

Time to get ready and move my customers to Windows 7 :-)

More on availability here: http://windowsteamblog.com/blogs/windows7/archive/2009/07/22/windows-7-has-been-released-to-manufacturing.aspx and http://windowsteamblog.com/blogs/windows7/archive/2009/07/21/when-will-you-get-windows-7-rtm.aspx

Countdown to August 6th has started!

#    Comments [0] |
# Monday, July 20, 2009

ReportViewer in VS2010

I’ve been using the ReportViewer control in Visual Studio quite a bit to create RDLC (offline) reports that are based on the result of LINQ queries against object trees. It’s been a while since there has been a new release of this control and Visual Studio 2010 did not include anything major with regards to the ReportViewer control. I asked around and got an email from Robert Bruckner answering my two main questions:

1. Yes, the ReportViewer control in VS2010 will run on both .NET 3.5 as well as .NET 4.0.
2. Yes, the ReportViewer control in VS2010 will support Export to Word for RDLC (offline) scenarios.

Thanks Robert (and the rest of the people working on this technology), great news!

#    Comments [8] |
# Tuesday, July 14, 2009

Urban Legends

I frequently receive emails in my inbox warning me about all sorts of scandals or terrible things that could happen to my health. Usually the person(s) forwarding these mails to me have my best interests at heart. Most of the time the emails are a hoax. I found a good site to check and see whether something is a hoax or not: http://urbanlegends.about.com/

#    Comments [1] |