Dynamically Call A Method, Using a String with Method Name

I was trying to set up a dynamic setup of algorithms in server side code which return true if they succeed, but I wanted users to be able to choose from a database generated list as to which algorithm they wished to run, unfortunately I wanted to be able to update the list dynamically without having to rebuild all the code, only the algorithm static class that contains the algorithm and the database that contains the names of all the classes but not modify the presentation layer.

After having a quick look around I found this code on an old faithful website codeproject.com with the perfect article which contained a simple solution to my problem.

Dynamically Invoke A Method, Given Strings with Method Name and Class Name by Matt Perdeck.

The solution I had only required some minor modification to make it work for me,

and to call it

Imagine a World, a better world. Where Games Workshop opened itself to the wonders of Digital Distribution

Imagine a World, for just a minute, a world where Games Workshop the company many of us has grown up knowing and loving from an early age fully embraced our brave new world of digital distribution. I have been following @thetalldesigner‘s blog, and in specific a particular article which takes the form of a wishlist, a realistic and achieveable wishlist which will usher in a new dawn for Games Workshop if they embraced the myriad of new technologies out there in our interconnected world. Check out the full article “What could Games Workshop produce if they fully embraced digital distribution of their rules?”.

This list is constantly being added to and improved upon and I would invite you to comment on his blog if there are any other features that have not been added. Below I have added a list of a few that I found particularly interesting.

Army Lists

  • PDF export of list for opponents use or tournaments
  • Share army list directly to your opponents via the system prior to the game

These would be great especially if you can link Games workshop accounts in a social fashion, you could have everyone from your local area and arrange games with vetted and legal lists.

  • Scenarios & extra missions Micro payments or subscriptions
  • Is this in stock at my local GW indicator
  • Access to older White Dwarf articles including scenarios, painting guides, battle reports etc. via a micro payment system. 50p an article. Monetises the huge back catalogue. Could also access the larger articles from older codexes.

To be honest, I’m surprised that Games Workshop hasn’t done this already. Apple has shown the value of mico-payments the $0.99 app. Considering the sheer number of articles that Games workshop have put out over the years, there could be a fortune in getting digital versions of just these articles, and the writers of White dwarf would be able to see exactly which parts of the magazine are the biggest attractions which will lead to better and better White Dwarfs.

My own addition would be an import/export functionality for third party software, they could even put the onus on the the third party software by defining a standard for import and export. Then third-party software would just need to add a new export option to convert their lists into GW Format (XML is ideal and not hard to do for this) and then you could make your army list in Army BuilderTM and then upload it to the site making it “official” before submitting it to the tournament page which could be set up by your local Games Workshop or gaming group.

Checkout the full article on Tetsugaku.

ASP.net CompareValidator for date validation issue solved

Now before I start this is not a problem with the control, as it turned out it was a problem with the environment. I had set up a text field to take a date and then validate that date using a DataTypeCheck in a ASP.Net CompareValidator. On my localhost and on the testing site I had no problems, and it only fired when the date was invalid (as you would expect), but on the laptop I found it had fallen over and would not save because the date was invalid.

The first problem was to find out was it actually the validator client side or server side as I have backup code int he event the user turns off JavaScript that performs the same job server-side. After a quick firebug and check of the server logs I determined that it was limited to client-side validation, which raised the question, why? Surely the testing server and the laptops JavaScript should not have changed, after deeper examination I came across the line in the client-side JavaScript.

DateValidator_13.dateorder = "mdy";

It was the american date format, it should have been “dmy”, this again raised the question why? Obviously it was a system setting, and after altering the IIS region setting to English (United Kingdom) problem solved. Just goes to show it pays to make sure all the environment settings are correct when deploying code onto a new machine.

Update: This has happened a couple of times, so to make sure the code is correct whatever machine this is deployed on I added  Culture=”en-GB” to the <%@ Page attribute, so that it associates with the correct culture wherever it is loaded.