November 2008 - Posts

C# Delegate Shortcut – No more null testing on events for subscribers

kick it on DotNetKicks.com

This is fairly well known but I realized I hadn’t seen it blogged about (sorry if already covered).

Your likely used to doing this:

  public event EventHandler<AnimationImageEventArgs> AnimationImageClicked;

       


 private void OnClick(object sender, AnimationImageEventArgs e)
     


   {
        


    if (AnimationImageClicked != null)
      


          AnimationImageClicked(sender, e);
     


   }

No need for that null check. I for one tend to forget them in the bowels of my teams code. What is better then eliminating the issue!

This is a way to ‘always have one subscriber’ which you can consider a sort of ‘null object’ pattern implementation for delegates. Checking for null just sucks and I love this kind of ubiquitous removal of it.

The first person I saw doing this was Juval Lowy, the master craftsman for basically all things .NET but known recently for utter mastery of WCF in his books and at his firm IDesign. Highly recommend all his writing, code samples and thoughts.

 public event EventHandler<AnimationImageEventArgs> AnimationImageClicked = delegate { };

        


private void OnClick(object sender, AnimationImageEventArgs e)
      


  {
     


           AnimationImageClicked(sender, e);
     


  }

Damon

Deep Zoom in 3D? See it here

Long story short, this is an effort to bring RIA to the SharePoint world.

But not just RIA style usability, I believe we pushed the envelope even further by incorporating not only DeepZoom (SeaDragon) for ‘zoom in to the pixel’ resolution, but the 3D extensions not present by default

(you have the essentials but only the amazingly talented people behind the Hard Rock Memorabilia site (vertigo) have shown this style of combined zoom/3d that we have seen in any largely deployed sample).

click.me

SharepointZoom3d

Click the image here to launch the Silverlight 2.0 cross-platform goodness.

NOTE: A prize goes to the first person to email us at: innovate@domaindotnet.com the exact number of seconds it would take to complete the ‘applying attributes’ to the .gif file (you need to see the demo to understand).

Related Posts

from tag wcf

from tag WCF

from tag silverlight

from tag SOA

from tag sharepoint

from tag Linq

(more..)

SharePoint MOSS 3D

a PowerPoint document in our breakthrough navigation and discovery technology

Damon Wilder Carr
domain.dot.net team labs
Page view counter