Scott Hanselman

Leaning on the Language and Leaning on the Libraries

February 22, 2006 Comment on this post [2] Posted in ASP.NET | Web Services | XmlSerializer | NCover | CodeRush | HttpHandler | Tools
Sponsored By

Coderush2What fun I'm having. I'm collaborating on a project for work. We're still using Visual Studio 2003 and .NET 1.1, but we're still wildly productive.

One interesting thing I've learned is that I lean on the libraries, while Paul, my counter-part leans on the language. He knows what language constructs to use and I know what BCL methods to use. Together we make an effective pair, but this realization helped us both better understand our weak areas. One can write lots of C in C#, if you know what I mean.

Do you lean on the language or the libraries?

We've been doing some fun stuff with XML lately, you might have noticed. We've used:

Also. we're using:

class KindOfPartialSgmlButMoreOfAnOfxXmlWriter : XmlWriter

{

    public KindOfPartialSgmlButMoreOfAnOfxXmlWriter(TextWriter w)

    {

        _htmlWriter = new HtmlTextWriter(w);

    }

 

    public override void Close()

    {

        _htmlWriter.Close();

    }

 

    private Stack _tags = new Stack();

    private HtmlTextWriter _htmlWriter = null;

    private bool _suppressNextEndElement = false;

    private bool _suppressNextText = false;

    private string _previousElement = null;

 

    public override void WriteStartElement(string prefix, string localName, string ns)

    {

        _htmlWriter.WriteFullBeginTag(localName);

        _previousElement = localName;

        _tags.Push(localName);

    }

 

    public override void WriteString(string text)

    {

        if (_suppressNextText == false)

        {

            _htmlWriter.Write(text);

            _suppressNextEndElement = true;

        }

    }

 

    public override void WriteEndElement()

    {

        string endtag = _tags.Pop() as string;

        if (_suppressNextEndElement && endtag == _previousElement)

        {

            _suppressNextEndElement = false;

        }

        else

        {

            _htmlWriter.WriteEndTag(endtag);

        }

    }

 

    public override void Flush()

    {

        _htmlWriter.Flush();

    }

 

    public override void WriteWhitespace(string ws)

    {

        _htmlWriter.Write(ws);

    }

 

    public override void WriteRaw(string data)

    {

        _htmlWriter.Write(data);

    }

 

    public override void WriteChars(char[] buffer, int index, int count)

    {

        _htmlWriter.Write(buffer, index, count);

    }

 

    public override void WriteQualifiedName(string localName, string ns)

    {

        _htmlWriter.WriteBeginTag(localName);

    }

 

    public override void WriteEndAttribute()

    {

        _suppressNextText = false;

    }

 

    public override void WriteStartAttribute(string prefix, string localName, string ns)

    {

        _suppressNextText = true;

    }

 

    public override void WriteRaw(char[] buffer, int index, int count)

    {

        _htmlWriter.Write(buffer,index,count);

    }

 

    public override void WriteProcessingInstruction(string name, string text)

    {

        _htmlWriter.Write(text);

    }

  

    #region Stubs

 

    ...here are overriden versions of everything else from XmlWriter, stubbed and not used. Removed for tidiness

 

    #endregion

}

 

 

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Hanselminutes Podcast 7

February 22, 2006 Comment on this post [0] Posted in Podcast | ASP.NET | XML | Tools
Sponsored By

HanselminutesMy seventh Podcast is up. This episode is all about XML. It wasn't nearly long enough to go into the detail I'd have liked. I need to focus! 

We're listed in the iTunes Podcast Directory, so I encourage you to subscribe with a single click (two in Firefox) with the button below. For those of you on slower connections there are lo-fi and torrent-based versions as well.

Subscribe to my Podcast in iTunes

Our sponsors are Automated QA, PeterBlum and the .NET Dev Journal.

Do take a look at TestComplete from Automated QA. It integrates with Visual Studio 2005 and I'm going to try to get a formal review of their stuff soon, particularly their functional Web Testing and Recording.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

  • Each show will include a number of links, and all those links will be posted along with the show on the site. There were 15 sites mentioned in this fifth episode, some planned, some not. We're still using Shrinkster.com on this show.
  • The basic MP3 feed is here, and the iPod friendly one is here. There's a number of other ways you can get it (streaming, straight download, etc) that are all up on the site just below the fold. I use iTunes, myself, to listen to most podcasts, but I also use FeedDemon and it's built in support.
  • Note that for now, because of bandwidth constraints, the feeds always have just the current show. If you want to get an old show (and because many Podcasting Clients aren't smart enough to not download the file more than once) you can always find them at http://www.hanselminutes.com.
  • I have, and will, also include the enclosures to this feed you're reading, so if you're already subscribed to ComputerZen and you're not interested in cluttering your life with another feed, you have the choice to get the 'cast as well.
  • If there's a topic you'd like to hear, perhaps one that is better spoken than presented on a blog, or a great tool you can't live without, contact me and I'll get it in the queue!

Enjoy. Who knows what'll happen in the next show?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

INETA ASP.NET Canada Roadshow

February 21, 2006 Comment on this post [4] Posted in ASP.NET | DasBlog | Internationalization | Speaking | HttpHandler | HttpModule | Web Services
Sponsored By

I'll be speaking in Vancouver, BC on March 6th, 2006 at .NET BC and in Victoria at the Victoria .NET Developers Group on March 7th, 2006. Both talks are about DasBlog, working on an Open Source application and what code you can steal/borrow from it. Two cities in a row qualifies as a Poor man's Canada Roadshow in my book.

"Scott Hanselman heads the DasBlog Open Source project along with Omar Shahine, following in the footsteps of Clemens Vasters and his dramatic modification of the BlogX engine. DasBlog is now on version 1.8 and is arguably the most successful ASP.NET blogging engine for the single user. DasBlog is now the work of many folks over many years and while it has some very hairy sections of code, it's full of design techniques and reusable components that you can use in your work today.

Topics Covered:

  • Httpmodules
  • Httphandlers
  • Background threads
  • Internationalization
  • Caching
  • Skinning
  • Creating a macro language
  • Web Services that are more than just SOAP
  • More architectural and design concepts that work in any ASP.NET application"

It should be fun. It'll just be me, but Omar will get mad props even though he won't be there. Omar and I have gone through two DasBlog releases together, first the big performance 1.7 release, then the follow-up 1.8 tightening. Currently 1.9 is in the hopper and will be the last .NET 1.x release as we work on a not-so-super-secret DasBlog.Next project. Currently the checked-in source is very much ahead of the 1.8 release with features like Pluggable Rich Editors with FCK and FTB support, Multi-Author/Single-Blog, Custom Plugin Macros, coComment support, and a much-improved commenting workflow.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Speaking at TechEd 2006

February 21, 2006 Comment on this post [3] Posted in ASP.NET | Corillian | TechEd | Speaking | Web Services | Tools
Sponsored By

Cool, Patrick and I are confirmed to speak at TechEd 2006 in Boston. We're talking as part of the architecture track and I think (hope) that our session's title stands out amongst the crowd and generates some buzz:

Dirty SOAP: A Dynamic Endpoint Without ASMX - How and Why? 

If you saw my TechEd 2003 Presentation called "Learning to Love WSDL" (IE only) you might find this new presentation interesting. The system that Patrick, I and others have designed for Financial Services is on version 2.2 now, and our strictly contract-first in-proc system is evolving, as planned, to support SOAP, POX, remoting, Tivo :), and all sorts of things. This system was designed to be, in some ways, future proof, with Indigo in mind. Our developers design their systems with XSD, WSDL (with our custom binding) and code generation and write code like this:

BankingServiceProxy banking = new BankingServiceProxy();
GetAccountsResponse res = banking.GetAccounts(new GetAccountsRequest());
if (res.Success)
{
   AccountCollection accounts = res.Accounts;
   foreach (Account a in accounts)
   {
      print(a.Balance); //or databind, etc...
   }  
}

This puts our developers in a nice familiar place (they've been doing things like this for ~2 years) when Indigo rolls along.

The presentation talks about how we are creating dynamic service endpoints for SOAP and POX, all in .NET 1.1, without ASMX and why we'd want to. (Remember that not everyone uses 2.0 and banks are conservative!) We'll also talk about the (currently being taken) next steps for 2.0 and and world of WinFX.

If you're in or around TechEd this June, be sure to say Hi!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

First Trip Away since Z and the magic of the webcam

February 21, 2006 Comment on this post [4] Posted in Z | Coding4Fun
Sponsored By

4600208.boxVideocamI'm down here in Birmingham, AL, on the first business trip since Z was born. He's 12 weeks old today. Thank goodness for Video Chat and Webcams.

I picked up an Airlink101 AIC250 at Fry's for $99. They are also available around the net. I was pricing wireless video IP cameras, but they are like $300+ for one that runs their one web server. I didn't want to get a cheapo button camera because I'd have to run the video output through my computer. The idea of a camera with it's own web server is/was very attractive to me.

This camera is interesting in that it includes Java and ActiveX controls that access the video stream. However, tinkerer that I am, that's not acceptable, so I started poking around. The results will turn into a Coding4Fun article and a .NET 2.0 ClickThrice application that's a modification of some code I found and modified with permission on CodeProject. Look for that soon, I should turn it in this week.

Here's some the interesting things that I found and done, as a teaser:

Motion  Tcptrace

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.