Simon Taylor - .Net developer, Cheltenham

My record of coding problems solved and new things discovered

Creating classes at runtime

clock June 14, 2009 21:55 by author Simon

I've been working on an application that has a number of forms that need to be laid out based on configuration data in the database, this enables the application to meet the requirements of many different customers. Laying out the forms based on the configuration data is relatively trivial - it is just a matter of writing the code that normally ends up in the .designer file. However, because there could be any number of controls on the form, binding an object to them is a little more tricky. I approached this problem by creating a class that describes a control that will added to the form together with a boolean, integer and string value field that is used to initialise the control and capture the users input based on the type of control. I had a list of these objects representing all of the controls that needed to be rendered on the form, to bind the controls to these objects, I needed an adapter which I created at runtime.More...

Currently rated 2.0 by 1 people

  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Passing an IronPython method to a C# method that takes a delegate as a parameter

clock June 14, 2009 21:42 by author Simon

This is again IronPython 101, but again took me a little bit of time to work out how to do it. Consider the following C# delegate and method:More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


IronPython String formatting and concatenation

clock June 14, 2009 21:33 by author Simon

This is really IronPython 101 but this was a really difficult thing to find by Googling! There are also examples in IronPython in Action but again, searching for them if you're not sure what you're searching for won't get you very far. The solution is pretty similar to how you would do it in C:More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Fixing detached users in SQLServer

clock June 14, 2009 21:15 by author Simon

Especially when you restore a database that was backed up on a different server to where you are restoring it to, a sql server database user can become detached from its corresponding login, which means you won't be able to login to the database as that user. To see if there are any users in this state and to fix the problem, you need to use the sp_change_users_login stored procedure.More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Encryptor

clock June 14, 2009 20:54 by author Simon

I've written an encryption utility that I find quite useful. There is nothing special about the code that does the encryption, but I have given it a command line interface and kept the actual encryption logic in a separate assembly which can be added to other applications. What I use this for is to manually encrypt data which I then put in a database which can then be decrypted by my application by adding a reference to the dll which has the encryption logic. More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Using JSON.Net

clock June 14, 2009 20:12 by author Simon

I was involved in a project on a customers ASP.Net CMS to embed a flex application which enables the user to enter some parameters and see how they affect the results which are displayed in a stacked bar-chart. The formula's that are used to calculate the results are highly sensitive therefore the logic could not be embedded in the flex application, therefore the only alternative was to expose some .net web services to provide the functionality. Although the data that is returned by the web services is basic and fairly minimal, from my experience of using flex, I was concerned that this wouldn't be as straight forward as it seemed. One of my concerns about consuming .net web services with flex was whether Microsoft actually adhere properly to web service standards, therefore I decided to return the data as JSON. This would mean that we wouldn't be relying on Microsoft to properly adhere to web service standards and my colleague who was writing the flex application had experience of consuming JSON, albeit from web services written using Ruby.More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


sharpcoder.co.uk available in 14 different languages!!!

clock June 14, 2009 18:44 by author Simon
Microsoft have created a translator widget (see right) that I have added to this site which allows readers to translate the text on the site, from English into 13 other lanuages. Guy Smith-Ferrier gives a very good description of what it does, how to get it and how to use it.

Currently rated 2.0 by 1 people

  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


About the author

Simon is Head of Engineering at Trigger Software, Cheltenham, UK. He is primarily a .Net developer although sometimes has to turn his hand to other technologies such as Java and Flex. Contact me.

Discount ASP

Sign in