↓ Skip to main content

Uncategorized

Convert a List in to a Collection

·1 min
If you have an object that contains a List or IList, and you need to convert it in to a Collection, here is how you can do it in a single line. var foo = new Collection<FooList>(fooList);

How to serialize/deserialize a nullable date

·2 mins
The time will come when you are serializing and deserializing object to and from XML that you will come across nullable dates, or more correctly an attribute XML date that is nullable. If you are like me and using the System.Xml.Serialization namespace, which make the complete process of serializing and deserializing so much easier.

Running Gallio tests using MSBuild

·1 min
When using a Continuous Integration server such as TeamCity, you’ll need to be able to perform the ability to run tests, the easiest and most controlled way is by writing your own MSBuild Script. Here is a little build script that finds all the test files and then runs them using Gallio, of course you need to reference the Gallio MSBuildTasks, in my case they are in C:\Program Files\Gallio\bin\Gallio.MsBuildTasks.dll

How does Home Server take those backups?

·25 mins
I’ve been using Home Server to take backups of all my machines on my network, and I am very pleased, it’s an install and forget service, which is nice for a change from Microsoft. Until I had to upgrade my server and install two new hard drives. I found my old backups were no longer available, this would not have been an issue until you need some information held on an old backup, which my Son did. So after many hours of trying I finally found a document that explains the complete process

Using MEF to provide PlugIns

·1 min
MEF has now been released, a Plug-In Framework, for .Net 4.0 After reading up on CodePlex, I have generated a small application that provides a plug-in framework, see attached below. http://mef.codeplex.com/wikipage?title=Guide&referringTitle=Overview MEF.zip (70.88 kb) I’ve also produced a .NET 3.5 version too:

How to use DataAnnotations Validation

·2 mins
The use of DataAnnotations, has increased over the years, as many frameworks are using it more and more, (MVC, Silverlight, etc). However if you need to perform validation within your application and it is not any known framework then can we still use DataAnnotations?

Code Coverage

·3 mins
 What is code coverage? Code coverage, in short, is all about how thoroughly your tests exercise your code base. The intent of tests, of course, is to verify that your code does what it’s expected to, but also to document what the code is expected to do. Taken further, code coverage can be considered as an indirect measure of quality — indirect because we’re talking about the degree to what our tests cover our code, or simply, the quality of tests. In other words, code coverage is not about verifying the end product’s quality.

Generating Sequence Diagrams

·1 min
From time to time I need to generate Sequence Diagrams, as this are required to graphically represent processes, as a consultant each customer has a different sent of tools you can and can not use. So it becomes hard to generate what should be something you don’t have to think about.

Validating XML against an XSD Schema

·2 mins
When handling XML files you are going to need to validate the XML, and the best way, currently, is to use an XSD Schema. It took me a little while to work out how to do this, and with help from Assaf Lavie I finally came up with a method to validate two streams, one holding the XML the other the XSD.

String to a Stream

·1 min
The time has come where I needed to handle streams, so the first I needed to generate some tests and within these tests I need to generate a stream based on some text. So the first task was to convert a String in to a Stream, and while I am at it how about the other direction to (Stream to a String)

Rapid Generation of test objects

·1 min
I came across a very easy to use and useful generation tool for objects today, NBuilder. Through a fluent, extensible interface, NBuilder allows you to rapidly create test data, automatically assigning values to properties and public fields that are of type of the built in .NET data types (e.g. ints and strings). NBuilder allows you to override for properties you are interested in using lambda expressions.

XSD Schema’s – Reference

·1 min
If you have ever come across generating XSD’s then you will soon find out that it’s a new ball game. So in order to help you along I have generated this reference point of items that I have found useful.

The need to generate an XSD from XML

·1 min
I came across a very simple to use XML to XSD generator today http://www.xmlforasp.net/CodeBank/System_Xml_Schema/BuildSchema/BuildXMLSchema/

AutoHotKey to increase productivity

·1 min
While attending a DotNetDevNet meeting in September 2009, by Stephen Oakman and Ronnie Barker, I remembered they used a tool called AutoHotKey, I’ve just revisited the tool and found it has increased my productivity, and combining it with Jean-Paul S. Boodhoo article for replacing spaces with underscores it is just perfect for generating unit tests.

WCF Message can only be read once

·1 min
WCF is a very powerful tool for developers, and I’m sure as you dive in to the development environment you will come across the WCF Message, which is part of System.ServiceModel.Channels Namespace. You should be aware that a message body can only be accessed once and a message can only be written once. This will in turn can cause a problem if you are creating your own IDispatchMessageInspector, as at some you will need to read the message and once you have read it, you are buggered!

XSD to Objects

·1 min
I’ve been dealing with REST services within WCF, and one thing that has come to my attention is that the calling service or third party only has access to the REST interface and the XSD’s.