Monthly archive - October 2009

FIX: When you undock some windows or change the window layout in the Visual Studio 2008 Service Pack 1 IDE, the IDE crashes

FIX: When you undock some windows or change the window layout in the Visual Studio 2008 Service Pack 1 IDE, the IDE crashes.

I just thought I re-post this incase anybody stumbled upon my blog before they landed on the Microsoft page that had the fix for IDE crashes. I experienced this only one time when I was moving/undocking windows.

Enjoy.

Helpful Extension Methods to the System.String Class in C#

I’ve been doing a decent amount of string manipulation lately and decided to combine that with my newfound knowledge about .NET extension methods. If you don’t know what extension methods are, they’re basically a way to extend a class without needing the source code to that particular class–hence why I can extend the System.String type by simply writing another class. The key is with the parameters of your methods. Here’s the basic gist of it:

public static {Your Return Type} {Your Method Name} ( this {Type/Class you want to extend} {Parameter Name} )
{
     /* Your method body */
}

 

So the key here is the “this” keyword before the type identifier in the parameter list of the method.

I’ve wrapped all of my extension methods into a single class simply called “ExtensionMethods” and added it to my project. The namespace doesn’t matter, so I haven’t included it in this example. You can either use the global namespace (though I don’t recommend it) or just create your own namespace called whatever you want.

Without further adue, here’s the code:

public static class ExtensionMethods
{
    /// <summary>
    /// Includes the trailing path delimiter.
    /// </summary>
    /// <param name="InputPath">The input path.</param>
    /// <returns>The input path including a trailing path delimiter if it doesn't have one</returns>
    public static string IncludeTrailingPathDelimiter(this string InputPath)
    {
        if (!InputPath.EndsWith(Path.DirectorySeparatorChar.ToString()) &&
            !InputPath.EndsWith(Path.AltDirectorySeparatorChar.ToString()))
            return InputPath + Path.DirectorySeparatorChar;
        return InputPath;
    }

    /// <summary>
    /// Asserts the trailing path delimiter.
    /// </summary>
    /// <param name="InputPath">The input path.</param>
    public static void AssertTrailingPathDelimiter(this string InputPath)
    {
        InputPath = InputPath.IncludeTrailingPathDelimiter();
    }

    /// <summary>
    /// Trims the extension from a file name.
    /// </summary>
    /// <param name="InputFile">The input file.</param>
    public static void TrimExtension(this string InputFile)
    {
        int start, count;
        if ((start = InputFile.LastIndexOf(".")) > 0)
        {
            count = InputFile.Length – start;
            InputFile = InputFile.Remove(start, count);
        }
    }

    /// <summary>
    /// Gets a file extension of a filename.
    /// </summary>
    /// <param name="InputFile">The input file.</param>
    /// <returns>The file extension</returns>
    public static string FileExtension(this string InputFile)
    {
        int start, count;
        if ((start = InputFile.LastIndexOf(".")) > 0)
        {
            count = InputFile.Length – start;
            return InputFile.Substring(start, count);
        }
        return string.Empty;
    }

}

 

Now whenever you use a System.String object, you’ll be able to simply call these methods as if they were part of the System.String class. IE: string MyFileExtension = MyFilePath.FileExtension();

I’m sure I’ll add on to this as I go along.

Now I really hate AT&T

So, as a continuation of my last post about how much I hate AT&T… the line tech finally come on site when they said he would. He apparently found a bad ring ground at the neighborhood’s equipment. He replaced it and my ringtone is now nice and clear and I consistently test at 6Mbps…. yay.

Well that lasted for a month or so. Now I’m down again. I replaced my modem entirely after the last occurrence of problems so that I could be better “supported”…. yes I put supported in quotes, because AT&T’s “support” is a joke to begin with. Now that I’m down again, the modem is giving some pretty good indicators as to why: “Could not find an ATM circuit.” Cute.

I call in and an automated message tells me that they’re “working to resolve a network outage in my area. The estimated resolution time is 12am.” I called at 3:30am. So, 3 1/2 hours have passed since their estimated resolution time. I know that this is an “estimate”, but seriously… 3 1/2 hours off? Some estimate, they might as well have simply said “We’ll be down for a while. In the mean time, play boardgames and jerk it to Playboy like the good ol’ days.”

I pressed zero and got to a support tech… we’ll call him “Albert” (real name was probably something closer to Habeeb Mohammednirishnikahnapali). I told him that I’m aware there’s a network outage, but the estimated time was midnight, it is now 3:30…. is my issue related to something else? He went through the motions like a good little AT&T drone…. ran the line test and attempted to get more information about the outage for me. He came back with the results of the line test: Line is good, but my area is still affected by an outage. And unfortunately the NEW estimated resolution time is “Monday.”

MONDAY!?!?! What the hell! I’ve been down since Thursday! I guess it will be pretty difficult to do things like pay my bills, turn in my school work, and perform my job functions. This is terrific. I should sue for lost wages or something… if any lawyers out there are planning to issue a class action lawsuit against AT&T, count me in. I don’t care what its for, count me in. I want to hit AT&T where it hurts. They only thing they value is money and I’d love to get mine back.

Luckily for me, I have T-Mobile cell phone service (because I dropped Cingular before the AT&T buy-out). I also have a Google Android phone with a tiny app called PdaNet. I’m forced to use the 2G internet connection that I have through my cell phone in order to do any online stuff. At least I have something, but I still can’t do any work-related stuff over this connection. I need a broadband connection for that.

Anyway, I’ll be calling AT&T and asking for a credit. I will only be paying AT MOST 87% of my bill if I am indeed down until Monday. I’m sick of paying for a full month of service, when I’m actually only getting about 20 days or so. This is a great way to start off the month of October… 4 day outage without a single notice to their customers.

Please somebody save me.