AddThis.NET: Google +1 Button for Blogengine

AddThis.NET is a Blogengine.NET extensions which adds social bookmarking buttons to all of your posts. It allows you to arrange each button individually, define the order of your buttons and enable and disable individual buttons. The version 5 contains the google +1 button and some fixed performance issues.

Supported Buttons

The AddThis button provides social bookmarking with nearly each bookmarking service that exists. Each button supports two different styles. It also provides a small button list provided by addthis, which also can be configured individually.

  • Google +1
  • AddThis Buttonlist
  • Facebook Like
  • Facebook Share
  • Twitter
  • Google Buzz
  • StumbeUpon
  • Digg
  • Tweetmeme (disabled by default)
  • DotnetShoutout (disabled by default)
  • DotnetKicks (disabled by default)
  • DotnetKicks.de (disabled by default)

Full feature list

It doesn’t only put them in your post, it also allows you to align each button individually (top left, top right, bottom left or bottom right). It also allows you to define a custom order of your buttons. Buttons can also be enabled per post by adding a HTML comment to your post. Here the full feature list:

  • Align each button individually (top-left, top-right, bottom-left, bottom-right)
  • Customizable order of your buttons
  • Enable or disable each button individually
  • Enable buttons per post by adding a HTML comment
  • Different button styles for each button
  • Hide buttons in post list and show them only in the single post view
  • Css class to attributes for each button and button list

Download and Installation

The installation is as easy as any other Blogengine.net extension. Download the file below, unzip and copy the data into the Blogengine.net extension folder. Or in a more detailed form:

  • Download the zip file below
  • Unzip the file
  • Copy the file “AddThis.cs” and the directory “BookmarkButtons”
  • Paste both into the “App_Code/Extensions” folder of your Blogengine.net directory
  • Open your Blogengine and open the extension section of your administration panel
  • Click edit settings for the AddThisDotNetv5 extension
  • Enable the buttons you need, disable the buttons you don’t need
  • Pay attention each button settings must be saved individually
  • Any settings of previous versions will be lost

Download AddThisDotNet Version 5 (18.83 kb)

.NET Links of the Week #42

A lot of articles about the new version of ASP.NET MVC this week. Seems every WPF and Silverlight guy does Windows Phone Dev now, no articles about WPF and Silverlight this week! Enjoy reading!

If you didn’t already read it, I released a new version of AddThis.NET, my social bookmarking extensions for Blogengine.NET. So if you use the old version or want to add some bookmarking buttons to your post (and you use Blogengine.NET) download it now and vote for it on DotnetKicks, DZone and DotnetShoutout!

Phone development

Integrate Html5 Form in ASP.NET MVC by Kazi Manzur
Code First Database Evolution (aka Migrations) by Entity Framework Design Team
The Windows Phone Developer Tools October 2010 Update by Windows Phone Team

.Net Framework

Improvements to Generated SQL in .NET 4.0 by ADO.NET Team
Inheritance Mapping: A Walkthrough Guide for Beginners by ADO.NET Team
Building the admin site with ASP.NET MVC3, NUPack & EF Code First by Jesse Liberty
Code Contracts (Part III): Evolution

ASP.Net

ASP.NET MVC 3 Beta: Strongly-typed views in Razor by Gunnar Peipman
jQuery Mobile – Optimizing your Website for Smartphone’s and Tablets by Dean Hume
Hanselminutes Podcast 236 – Misunderstanding REST by Scott Hanselman
ASP.NET MVC 3: New @model keyword in Razor by Scott Gu
Dean Hume – Dot Less and Minifying Css by Dean Hume

Tools and Libraries

Creating Desktop Applications with Messenger Connect by Windows Live Blog
KiGG 3.0 Released by Mosessaur
What’s New in jQuery 1.4.3 by Craig Buckler

AddThis.NET: Social Bookmarking Buttons for Blogengine

AddThis.NET is a Blogengine.NET extensions which adds social bookmarking buttons to all of your posts. It allows you to arrange each button individually, define the order of your buttons and enable and disable individual buttons. The version 5 contains the google +1 button and some fixed performance issues.

Supported Buttons

The AddThis button provides social bookmarking with nearly each bookmarking service that exists. Each button supports two different styles. It also provides a small button list provided by addthis, which also can be configured individually.

  • Google +1
  • AddThis Buttonlist
  • Facebook Like
  • Facebook Share
  • Twitter
  • Google Buzz
  • StumbeUpon
  • Digg
  • Tweetmeme (disabled by default)
  • DotnetShoutout (disabled by default)
  • DotnetKicks (disabled by default)
  • DotnetKicks.de (disabled by default)

Full feature list

It doesn’t only put them in your post, it also allows you to align each button individually (top left, top right, bottom left or bottom right). It also allows you to define a custom order of your buttons. Buttons can also be enabled per post by adding a HTML comment to your post. Here the full feature list:

  • Align each button individually (top-left, top-right, bottom-left, bottom-right)
  • Customizable order of your buttons
  • Enable or disable each button individually
  • Enable buttons per post by adding a HTML comment
  • Different button styles for each button
  • Hide buttons in post list and show them only in the single post view
  • Css class to attributes for each button and button list

Download and Installation

The installation is as easy as any other Blogengine.net extension. Download the file below, unzip and copy the data into the Blogengine.net extension folder. Or in a more detailed form:

  • Download the zip file below
  • Unzip the file
  • Copy the file “AddThis.cs” and the directory “BookmarkButtons”
  • Paste both into the “App_Code/Extensions” folder of your Blogengine.net directory
  • Open your Blogengine and open the extension section of your administration panel
  • Click edit settings for the AddThisDotNetv5 extension
  • Enable the buttons you need, disable the buttons you don’t need
  • Pay attention each button settings must be saved individually
  • Any settings of previous versions will be lost

Download AddThisDotNet Version 5 (18.83 kb)

.NET Links of the Week #40

The new packaging manager NuPack has been released this week, so some articles about that topic. Also a new version of mono has been released last week! Enjoy reading!

Phone development

Introducing App Hub for Windows Phone 7 by Windows Phone Dev Team
App Hub is the place where you can submit your Windows Phone 7 app

iPhone to Windows Phone 7 – XNA, Animation and Games by Jesse Liberty
Great series, this episode about graphics and gaming

Yet Another Podcast – Show 5 – Programming Windows Phone 7 by Jesse Liberty
Podcast about programming Windows Phone with Jeffrey Blankenburg

.Net Framework

Attributes Every .NET Developer Should Know About on Devcurry
Shows most of the important attributes which are present in .NET Class Library

Entity Designer Improvements Preview by EF Design Team
The team shows the improvements of the EF Designer in a future version

Object Caching – .NET 4 by Dean Hume
Article about Caching in .NET in common

WPF and Silverlight

Deploying Silverlight assemblies via NuPack by Tim Heuer
Shows how Silverlight projects can be deployed with the new package manager (NuPack)

JavaScript vs Silverlight: An answer by Laurent Bugnion
Article about Silverlight and Javascript and which should be preffered

ASP.Net

Using external templates with jQuery Templates by Dave Ward
Explains how external templates can the used in jQuery

ASP.NET MVC 3 Beta Released by Phil Haack
Just a great picture of a cat :) nothing more to add..

Understanding jQuery’s impact on Microsoft and ASP.NET by Dave Ward
ASP.NET Ajax Library gets killed by jQuery

Tools and Libraries

Mono 2.8 is out
A new version of the .NET Framework for Linux is out, which now also supports C# 4.0

Introducing NuPack Package Management for .NET by Scott Hanselman
Walk through about NuPack the new packaging manager

Introducing NuPack Package Manager by Phil Haack
Phil Haack about the new packaging manager

Visual Studio 2010 Survey by Jason Zander
Survey about Visual Studio by Microsoft

.NET Links of the Week #39

Last week a lot of Windows Phone 7 tutorials were published (if you are interested in WP7 dev, don’t miss the developer launch webcast). There were also some good articles from the MSDN Magazine in my weekly list. Enjoy reading!

Phone development

Microsoft Visual Basic CTP for Windows Phone Developer Tools Tutorial by Jason Zander

Windows Phone 7 Developer Training events by Tim Heuer

Simulcast: Windows Phone 7 Developer Launch by Windows Phone Developer Team

Windows Phone 7: Navigation by Jesse Liberty

Mobile Apps: Getting Started with Windows Phone Development Tools by MSDN Magazine

.Net Framework

WCF Data Services Client Library and Windows Phone 7 by WCF Data Services Team

Fully Qualified Path in .NET on DevCurry by Suprotim Agarwal

Entity Framework Preview: code first, ObjectSet and DbContext by MSDN Magazine

Thread Pools: Scalable Multithreaded Programming with Thread Pools by MSDN Magazine

Object databases for .NET with LINQ support

Building a CRUD in RESTful Services of WCF by Abhishek Sur

Getting Started with WCF RIA Services by Dinesh Sodani

WPF and Silverlight

Yet Another Podcast Show #3 – John Papa on MVVM and Patterns by Jesse Libery

Herding Code 94: Silverlight and HTML5

ASP.Net

Detect Mobile Device using ASP.NET on DevCurry by Suprotim Agarwal

jQuery Templates, Data Link, and Globalization Accepted as Official jQuery Plugins by Scott Gu

Bing Maps: Adding and tracking pushpins using JavaScript by Gunnar Peipman

5 Ways HTML5 can Speed Up Your ASP.NET Application

Tools and Libraries

The Ultimate Guide (of Five Things) for New IE9 users Who Fear Change by Scott Hanselman

5 Easy Tips to Reduce and Refactor Your Code with Resharper by John Papa

Thread local variables with ThreadLocal(T)

.NET 4.0 provides a thread local storage, simply by adding a field of type ThreadLocal<T>. The field will have a different instance for each thread! Have a look at the following sample:

public class ThreadLocalSample
{
    static ThreadLocal<int> count = new ThreadLocal<int>(() => 10);

    public ThreadLocalSample()
    {
        new Thread(minus).Start();

        for (int i = 0; i < short.MaxValue; i++)
        {
            count.Value++;
        }

        Console.WriteLine("Add: Local Thread Variable = {0}", count.Value);
    }

    private void minus()
    {
        for (int i = 0; i < short.MaxValue; i++)
        {
            count.Value--;
        }

        Console.WriteLine("Minus: Local Thread Variable = {0}", count.Value);
    }
}

The feature also exits before version .NET 4.0, you simply have to decorate a static field with ThreadStaticAttribute. It has the same effect than using ThreadLocal<T>!

.NET Links of the Week #38

It looks like there are only Windows Phone 7 developers out there if you read the news from the last week. I only put a few of them into my list! Enjoy reading!

WPF and Silverlight

WPF Tutorial : Styles, Triggers and Animations by Abhishek Sur

Custom Placement within an ItemsControl in WPF by Pete Brown

Phone development

Windows Phone 7 Developer Tools Released by Scott Gu

Windows Phone 7 Emulator Unlocked

Microsoft Visual Basic CTP for Windows Phone Developer Tools Tutorial by Jason Zander

Reactive Extensions Phone 7 samples in VB

Windows Phone 7 for Silverlight Programmers – Launchers and Choosers by Jesse Liberty

Handling picture orientation in CameraCaptureTask in Windows Phone 7 by Tim Heuer

.Net Framework

Reactive Extensions in .NET – Hot & Cold Observable

Getting Started with Entity Framework 4.0 Screencast Part 5 by Muhammad Mosa

Friend assemblies in .NET by Agafonov Viacheslav

Partial Methods – An Uncommon Note by Abhishek Sur

Vote for your favourite .NET DI (IoC) Framework

Unity, Castle Windsor, StructureMap, Ninject – who has best performance? by Gunnar Peipman

EF Caching with Jarek Kowalski’s Provider by ADO.NET Team

ASP.Net

jQuery UI on the Microsoft CDN by Stephen Walter

6,953 reasons why I still let Google host jQuery for me by Dave Ward

ASP.NET MVC: Using asynchronous controller to call web services by Gunnar Peipman

Tools and Libraries

The Ultimate Guide (of Five Things) for New IE9 users Who Fear Change by Scott Hanselman

Make your application extensible with Reflection

Sometimes I’m very thankful when a application is extensible. It allows you to customize a application or event extend a application in a easy way. Otherwise, if the code is public, I have to digg through the code and search for a place where I can add my functionality. If I’m speaking about extensible I mean it in a technical manner where normally dependency injection frameworks will be used. But what do you use in a small application where you don’t have MEF, some “old” .NET 3.5 app, and a dependency injection framework like Structuremap is too big or the know how is missing? 

If you only want to provide extensibity, which means load all object of a specific type and process a action foreach object in a generic way, why not use old, classic reflection?

public static List<T> LoadAll<T>()
{
    List<T> services = new List<T>();

    foreach (Type type in Assembly.GetCallingAssembly().GetTypes())
    {
        if (type.IsSubclassOf(typeof(T)) && !type.IsAbstract && !type.IsInterface)
        {
            services.Add((T)Activator.CreateInstance(type));
        }
    }

    return services;
}

Shure you have to adapt your class design (it only works with empty constructors) and have to implement additional interfaces if you want to split a group with the same base class, but it’s simple, everyone knows what it does and how to handle. I used the code above in several projects (sometimes I thought i would exchange it later with a real dependency injection framework, which never happened) and also in my generic chain of responsibilty builder!

Generic approach to access WCF Data Services

WCF Data Services allows to publish your data very fast and easy. If you use Visual Studio to create the client which consumes the services, you just can have to click “add service reference” and you have the classes you need to work with the service are generated (a sample for WCF Data Service you will find in my previous post). But what if you have a bunch of services which all follows the same convention and you want to access them in a generic way? This is also as simple as accessing the service with the generated stub. As a sample service we use one which returns all the startup date and time of the service (uses EF CT4 which can be downloaded here)

public class ServerInfo
{
    public int ID { get; set; }
    public DateTime Startup { get; set; }
}

public class ServerContext : DbContext
{
    public DbSet ServerInfos { get; set; }
}

[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class ServerInfoService : DataService<ServerContext> 
{
    public static void InitializeService(DataServiceConfiguration config)
    {
        ServerContext conn = new ServerContext();
        conn.ServerInfos.Add(new ServerInfo() { Startup = DateTime.Now });
        conn.SaveChanges();       
        config.SetEntitySetAccessRule("*", EntitySetRights.All);
    }
}

All you need to access the service is the URL (of the service and the data). So you can use the base classes to call the service. But you still need a data container. WCF Data Services supports custom class binding, which means if a class contains the properties with the same name than the source class, the data will be mapped to these property. You have also the possibility to configure that missing properties in the destination class will be ignored.

public class ServerInfo
{
    public DateTime Startup { get; set; }
}

static void Main(string[] args)
{
    var serveruri = new Uri("http://localhost:7640/ServerInfoService.svc");
    var datauri = new Uri("/ServerInfos", UriKind.Relative);

    var context = new DataServiceContext(serveruri);
    context.IgnoreMissingProperties = true;

    var infos = context.Execute<ServerInfo>(datauri);

    foreach (var values in infos)
    {
        Console.WriteLine(values.Startup);
    }

    Console.ReadLine(); 
}

The DataServiceContext replaces your custom context class. To load the collection of ServerInfo objects, which normally would be accessed over a generated property, the generic method execute will be called. The data will be mapped automatically to the new class. When the property “IgnoreMissingProperties” is set to true, the mapping will also cause no failure if a property is missing!

Download the source code

.NET Links of the Week #36

This week my .NET links will be released some days earlier than usual, because I will leave for holidays tomorrow! Enjoy reading!

WPF and Silverlight

Introducing JetPack–a new Silverlight 4 application theme by Tim Heuer

Consuming WCF Service in Silverlight4 Projects by Hima on Beyond Rational

WPF & Silverlight at risk from Microsoft’s passion for HTML5 by Mike James on I-Programmer

Styles in Silverlight by Dinesh Sodani on Beyond Relational

Phone development

iPhone to Windows Phone 7: Lists and Details by Jesse Liberty

Using the Accelerometer on Windows Phone 7 by Windows Phone Team

.Net Framework

How to Create WCF 4.0 Service and Hosting in IIS 7.5 on CodeGain

Passing parameters by value & by reference

List<T> internals and performance when adding new elements by Gunnar Peipman

Data Binding with DbContext by Entity Framework Design Team

ASP.Net

Rotate Ads using jQuery and ASP.NET AdRotator Control by Suprotim Agarwal on DotnetCurry

A simple mvc example to view and edit .NET resource (*.resx) files

Making async calls to web services during ASP.NET page processing by Gunnar Peipman

Overriding a .svc Request With Routing by Phil Haack

Tools and Libraries

Common mistakes made when measuring the speed of code by Gunnar Peipman

Introducing the Microsoft Web Farm Framework by Scott Guthrie

Power Commands for Visual Studio 2010 – Extension #8 by Sara Ford