Skip to main content

Posts

Showing posts from 2012

Binding Enum with DescriptionAttribute in WPF

Binding an enumeration to a ComboBox can be done in several ways. In most cases you don't want to display the value itself, but a more user friendly description. One common approach is to use the DescriptionAttribute on the Enum values to supply a description for each value.  This is all possible in a very MVVM friendly way. First step is to add the  DescriptionAttribute  to the values of the enumeration. public enum MyValues { [Description("First value")] First, [Description("Second value")] Second } To retrieve the description from the enum we use a simple extension method. This method returns the value of the DescriptionAttribute if it exists, otherwise the string representation of the enum value is returned. public static string GetDescription(this Enum value) { var fieldInfo = value.GetType().GetField(value.ToString()); var attribute = fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false).FirstOrDefault() as

LEAP Sweden in Redmond

Well, there is not very much to say about the trip to Redmond, except that it was awesome! It has been a week filled with seminars and social activities in Microsoft Conference Center and closeby venues. We even paid a visit to The Flight Museum outside Seattle and actually got a private tour from Clemens Vasters, who knew surprisingly much about airplanes. Not only have I been able to meet other extremely talented developers and architects who participated in the LEAP program, I've also had the chance to meet some of the most involved people at Microsoft and got to hear about the latest and hottest topics in IT today. The speakers included Jonathan de Halleux , Stuart Kwan, Scott Guthrie , Miha Kralj , Clemens Vasters ,  Cihan Biyikoglu ,  Bryan Agnetta and more. The topics were everything from theoretical architectural lectures to deep product previews and technical discussions. Overall it was a great schedule packed with so much information I almost don't know what to d

LEAP Sweden - Windows 8 and Windows Server 2012

I am back home in the couch filled with enthusiasm from the last gathering of LEAP Sweden before the trip to Redmond in the end of May. Todays topic was the new versions of Windows (server and client) as well as the Business Intelligence product suite from Microsoft. The Business Intelligence suite basically is a really nice integration between products that already exist. With SQL Server 2012 , SharePoint 2010 and Excel 2010 tightly integrated Microsoft offers a really attractive package. Mikael Nyström showed off some of the new features in Windows Server 2012 . To say the least this is an impressive release. There is a heavy focus on virtualization, storage and terminal services which makes Microsoft a strong competitor against both VMWare and Citrix in the small to medium sized business segment. One of the coolest features has to be conditional permissions. Johan Lindfors gave a demo on Windows 8 development . He showed some samples of how easy it is to develop Metro s

Connecting to SOAP service with certificate authentication

I have rarely worked with certificate based authentication, so when I got this neat little SOAP service with certificate authentication in my hands I gladly accepted the challenge. All I got was the URL to the service with a certificate and the password. I also got an example written in PHP: $client = new SoapClient("https://url.to.service/", array(         'local_cert' => 'client_certificate.pem', 'passphrase' => 'PASSPHRASE',         'cache_wsdl' => WSDL_CACHE_NONE )); This of course looks very easy, but we all know that it's not really that easy if I want to use .NET and WCF. First of all the PEM-certificate cannot natively be used in .NET. Second of all I don't have the WSDL for the service. Here are the steps I had to go through to be able to successfully connect to the SOAP service. Convert the certificate The certificate I received was a PEM certificate which included both the private and public key. .NET

Quartz.NET and MEF

I have been implementing a scheduler service for several different jobs on several difference schedules, which led me into using Quartz.NET . This is a really nice framework, but since we're using MEF I ran into some issues. Quartz.NET  basically consists of the scheduler engine which runs jobs implementing the IJob interface. The interface simply consists of an Execute method. I export each job with the IJob interface using  MEF . [Export(typeof(IJob))] public class MyJob : IJob { public void Execute(JobExecutionContext context) { ... } } In my scheduler implementation the jobs are imported into an IEnumerable<IJob>. [ImportMany(typeof(IJob))] public IEnumerable<IJob> Jobs { get; set; } The initialization of the scheduled tasks is pretty straight forward. A standard scheduler factory is initialized which in turn gives us a scheduler instance. Each job that was imported by  MEF  is then added to the scheduler, here with a simple 10 min

LEAP Sweden - Identity & Access Management

Today was the third day of the Swedish Lead Enterprise Architect Program at Microsoft in Kista. It has been a day filled with sessions on security and identity with a kind of unavoidable focus on federated identities in the cloud. Overall it has been an awesome day with seminars from Henrik Nilsson , Barry O'Reilly and Sergio Molero among others. A lot of Microsoft technologies was mentioned, Forefront Identity Manager , Active Directory Federation Services 2.0 , Forefront Unified Access Gateway , Direct Access ,  Windows Identity Framework and of course  Azure Access Control Service . Microsoft really has a great suite of applications regarding Identity & Access Management. I just wish there was a project or two where I could utilize all of these amazing technologies. I have had a plan to add a login feature to the Cornball using federated identities, so that might happen in the near future. Besides, Björn Eriksen provided a tip for all of us thursty for education.

First gathering of LEAP Sweden 2012

I am back home in the couch after the second day on the first gathering of Microsoft LEAP Sweden 2012 . It has been two days packed with lectures on architecture and cloud computing. Without giving away too much, here are some short notes from this first gathering: In software arcitecture, knowing your patterns and practices is always a good thing. The same goes for best practices. SOLID is not a new concept, but it bears repeating! The future is all about bring-you-own-device , the cloud in general and  Azure  in particular. Also, the future is now! The Windows Azure HPC Scheduler is awesome for high performance computing scenarios where an extra boost is needed. You gotta love the elastic cloud! I will start working on a Rock Paper Azure bot this weekend and try to conquer the world. The speakers that shared this information with us were among others Patrik Löwendahl ,  Brian Prince  and of course  Björn Eriksen  that is organizing all of this. I am already l

Binding a HTML-formatted string to a WPF WebBrowser control

Sometimes there is a need to display a HTML formatted string in a WPF application. There are a couple of ways to do this, but the most stright forward is to use a WebBrowser control and the NavigateToString method. This approach has one big flaw, you cannot use binding to a string out of the box, but I found a great solution through Stack Overflow which adds a bindable property to the  WebBrowser  control using  NavigateToString . The following class is all that is needed to add that behavior. A new depencency property named Html is introduced to the  WebBrowser  and the proper change action is performed in the OnHtmlChanged method. public class BrowserBehavior { public static readonly DependencyProperty HtmlProperty = DependencyProperty.RegisterAttached( "Html", typeof(string), typeof(BrowserBehavior), new FrameworkPropertyMetadata(OnHtmlChanged)); [AttachedPropertyBrowsableForType(typeof(WebBrowser))] public static string GetHtml(WebBrowser bro

New Silverlight 5 features in The Cornball

The release of Silverlight 5 is allegedly the last major release of Silverlight , but it brought some great stuff that I have now incorporated in the latest release of The Cornball . There are a lot of good descriptions and even video samples of the new features in  What's new in Silverlight 5 . These are the two new features that I am using in The Cornball . Mouse Button Double Click Previously I have used a custom implementation with a timer to capture double clicks on the cards. But since this feature finally is included in the framework I decided to use that instead. The MouseButtonEventArgs now has a ClickCount property which simply indicates the number of times the mouse button was clicked. That leaves us with a much cleaner implementation of the single and double click scenario. private void CardMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { switch (e.ClickCount) { case 1: // Handle single click break; case 2:

Microsoft LEAP Sweden 2012

I have been privileged to participate in the  Lead Enterprise Architect Program  at Microsoft this spring. The Lead Enterprise Architect Program (LEAP) is a program that aims to give understanding of the strategic core components of the Microsoft platform. LEAP consists of five master class training sessions as well as three days of sessions at Microsoft headquarters in Redmond, Seattle. The direction of the classes are extremely appealing and I really hope that they will live up to my expectations: Application architecture on the Microsoft Platform Cloud computing for Architects Identity & Access Management Integration on premises and in the cloud Business Intelligence and Enterprise Search The program starts in February and ends with the trip to Redmond in the end of May. During this time I will try to write as much as possible about this whole experience, which I hope will be amazing!

My experience with TFS Preview

I have been using the Team Foundation Services preview for a while now, and the least I can say is that I am impressed! The web interface has a nice Metro style design and gives a high quality experience overall. By installing the KB2581206  hotfix I can also access my TFS account from Visual Studio, which is absolutely fantastic. I might even sound a bit fanatic by saying that it is like a dream come true... The server appears as a traditional Team Foundation Server in Visual Studio apart from the logon process (a Windows Live popup window). Read more and try it out yourself! Besides playing around with the user interface I have actually tried to work a little seriously with the service as well. Partly by uploading my project the Cornball and developing against the TFS in Visual Studio. So far this experience is very positive and I have not found any issues or oddities at all, except that the environment is kind of slow. This whole thing also takes me one step further out in th

Google Search Appliance .NET solution

I recently worked on a project to integrate the search results from a Google Search Appliance into a .NET application. Although it seems like a pretty straight forward task, there were some small issues that I thought I might share. Background The communication with the Google Search Appliance is made simply with a HTTP GET request, which returns an XML formatted response. As for the Suggest service, the request looks about the same but the result returned is JSON encoded. For more information, please see the Google Search Appliance documentation , which is very extensive. Internationalization Since this solution was to incorporate several languages, the .NET application had to support and differentiate the languages. The GSA has very good built-in language support but there were at least one thing that was not completely obvious. The GSA uses either HTTP headers or query string parameters to determine in which language the request is made. If neither of these are supplied the