↓ Skip to main content
The technical notebook of Bryan Avery

Ideas worth sharing.

Practical notes on software architecture, cloud platforms, security and AI. Written from real engineering experience, with an eye on what actually works.

A little about me

Latest articles

553 articles in the archive

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.

MVVM Material

·1 min
After attending a talk on Silverlight 4, MVVM and TDD with Jesse Liberty, I thought it would be an idea to find out more information on MVVM, James Green provided me with a number of worth while links by Jason Dollinger from Lab49. The main blog post is here http://blog.lab49.com/archives/2650 but the actual video is here http://www.lab49.com/files/videos/Jason%20Dolinger%20MVVM.wmv big download (about 1.5 hours).

Passing Validation exceptions via WCF REST

·1 min
When using WCF and Rest one thing you’re going to have to consider is the validation of the object, the way to do this is using the Validation Application Block included in the Microsoft Enterprise Library to validate the data transfer objects. This way you can decorate the objects with attributes to validated the objects

Lifestyles of the Castle Windsor IoC Containers

·1 min
It’s worth knowing how the Castle Windsor IoC work, by default it uses Singletons, where this will work for the most of the time, there are a lot more options available to you depending on your needs. These lifestyles that are available in Castle Windsor are:

MVC 2 makes it easier to copy models

·1 min
With MVC 2 now released, I have found a nice little feature for updating models. The normal practice is to use, a mapping technique like this public void Save(EmployeeViewModel employeeViewModel) { var employee = (from emp in dataContext.Employees where emp.EmployeeID == employeeViewModel.EmployeeID select emp).SingleOrDefault();

Introduction to Dependency Injection

·4 mins
Dependency Injection (DI) is an incredibly useful and easy technique which makes your code a lot easier to test. I like to use samples to explain Dependency Injection. We’ll use a SqlMetaDataProvider class which needs to provide the meta data coming from a SQL Server database. It retrieves the meta data from the database in a relational structure (a DataSet) and then converts it to an easy to use object model. Obviously, i want to be able to test this class without actually going to the database because that would make the tests slow. So how can we test if the relational data is being converted to the object model without going to the database?

Using REST via WCF

·1 min
With WCF now being around for some time, it supports many protocols, mainly SOAP, but it does also support Rest, the question is how do you do it? Well I have got the sample working from the MSDN Magazine. If you’d like the full detailed explaintation then you can go to An Introduction To RESTful Services With WCF