Home Contact

X

Coder, not artist.

News

All code on here is free, but as a consequence it's up to you to check it, ha! If you have any questions, please use the contact button!

Twitter












Archives

Post Categories

Image Galleries

Syndication:

C#


C Sharp

Mocking ITable<T>

I have to do some mocking of an ITable to be able to test some of my code, as you may imagine this is the point where we’re crossing the data boundary… Now, ITable is a total bugger to mock, I’ve tried on (at least) 3 separate occasions to get it mocked, and have only now, finally achieved an 80% solution. (Nothing is ever 100%) I’m not using any mock framework, they just take too long to setup (in this case) and instead have a concrete class that implements ITable and uses an IList as it’s base....
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

InitParams in Silverlight – passed via MVC

The old skool way of passing InitParams in aspx is well documented, adding a: <param name="initParams" value="<%=InitParams%>" /> which is accessing the public ‘InitParams’ member in the code-behind file, which is inevitably set up via the ‘Page_Init’ handler. All well and good, but not practical in MVC, so… how to do this? (NB. This is just how I’ve done it, it’s not the only solution) There are a few things to change: 1. The Model I’ve created a SilverlightHostModel, it only has one...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Comprehensive redesigns

So, last night I realised that I’d made some bad decisions with the database, structure and naming, so… I’ve now refactored it all, and I’m feeling… hmmm… meh about it. I suspect I will redo it all later, but for now it will do…. I’ve also come to the conclusion that I was maybe trying too much for the initial release, so as a consequence I have removed one part of the project… (which, by-the-by, I intend to have published in a month or so – and yes Andy, that is one month longer than I mentioned...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

MousePath

A while ago, (and by that I mean over a year ago now) I was catching up on the blogs I read and came across this post: http://blog.iso50.com/14644... I thought – Awesomeness! I’ll give that a go… downloaded the app, and ran it, all good – but only on one monitor… :( I work with two monitors, and found that a lot of the time I’d end up with a no lines as I was on the other monitor… So, I thought I’d give it a go and write one myself… I actually had a working version pretty...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

It’s ok to throw System.Exception…

No. No it’s not. It’s not just me saying that, it’s the Microsoft guidelines: http://msdn.microsoft.com/e... Do not throw System.Exception or System.SystemException. Also – as important: Do not catch System.Exception or System.SystemException in framework code, unless you intend to re-throw.. Throwing: Always, always try to pick the most specific exception type you can, if the parameter you have received in your method is null, throw an ArgumentNullException, value received...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Unknown C# keywords: params

Often overlooked, and (some may say) unloved, is the params keyword, but it’s an awesome keyword, and one you should definitely check out. What does it do? Well, it lets you specify a single parameter that can have a variable number of arguments. You what? Best shown with an example, let’s say we write an add method: public int Add(int first, int second) { return first + second; } meh, it’s alright, does what it says on the tin, but it’s not exactly awe-inspiring… Oh noes! You need to add 3 things...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Deploying, but without those pesky test files!

Silverlight testing is great, we all know that (don’t we??), we’re expected to do it as part of the development process, but once we’ve got an awesome application written and we come to deploy it, we don’t want the test files going out with it… You might be like me, have the files in a Web project – let’s face it, that’s how we’re pushed into doing it… So let’s stick with it! Now. I’m deploying via the wonders of the Web Deployment shizzle, but this also applies to the classic ‘installer’ project...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Enum driving a Visual State change via the ViewModel

Exciting title eh? So, here’s the problem, I want to use my ViewModel to drive my Visual State, I’ve used the ‘DataStateBehavior’ before, but the trouble with it is that it only works for bool values, and the minute you jump to more than 2 Visual States, you’re kind of screwed. A quick search has shown up a couple of points of interest, first, the DataStateSwitchBehavior, which is part of the Expression Samples (on Codeplex), and also available via Pete Blois’ blog. The second interest is to use...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Publishing a DeepZoom project to IIS

I’ve just been helping a colleague work out how to publish their Silverlight DeepZoom project to their local IIS instance. Went through the Publish settings in VS2010, published, connected to it via IE and… ah. No Images. OK, no worries, let’s copy the files from the ClientBin folder across that weren’t published… Hmmm, still no joy… Seems to be just the zoom images that aren’t there… Ok, how about trying to access those files.. You get this error when you attempt to access the .dzc file directly:...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Path Animation in Silverlight

I’ve been spending some time working on prototyping some things I want to get working for a game I’m developing, and one thing I wanted was to get a couple of fly’s flying (buzzing?) around a lightbulb. Ideally I wanted to draw a path and say – Fly – use this path and follow it until the end of time! Turns out in WPF I could do this, but not so in Silverlight. Everything I saw explaining how to do it, involved working out complex (to me) equations to get the motion correct, or using a set of key...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Full C# Archive