Tuesday, August 31, 2010
Source code for the WSDOT iPhone application
Source code for the WSDOT iPhone application
Monday, August 30, 2010
Thursday, August 26, 2010
My odd sql variable names
Tonight I was looking through some code looking for a snippet of SQL that I wrote ages ago that I quickly wanted to hack and modify for something I am working on when I came across this:
This wasn’t what I was looking obviously but it has made me chuckle.
The Downside Of Providing An API Through Extension Methods
Moq and Rhino Mocks intellisense
Wednesday, August 25, 2010
Internet Explorer 9 UI Revealed
Tuesday, August 24, 2010
Log Reporting Dashboard for ASP.NET MVC
Integrates Log4Net, NLog, Elmah, and ASP.NET Health Monitoring into an ASP.NET MVC 2.0 Website and provide a log reporting dashboard.
Looks a very good article on the code project
My .NET ICache
.NET caching code used to help improve testability, swap out different implementations, and enhance the API.
http://openmymind.net/2010/8/24/My-DOTNET-ICache#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | using System; using System.Web.Caching; public interface ICache { T Get<T>(string key, params object[] keyArgs); T Fetch<T>(string key, Func<T> callIfGetReturnsNull, params object[] keyArgs); T Fetch<T>(string key, Func<T> callIfGetReturnsNull, DateTime absoluteExpiration, params object[] keyArgs); T Fetch<T>(string key, Func<T> callIfGetReturnsNull, TimeSpan slidingExpiration, params object[] keyArgs); T Fetch<T>(string key, Func<T> callIfGetReturnsNull, CacheDependency dependencies, params object[] keyArgs); T Fetch<T>(string key, Func<T> callIfGetReturnsNull, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, params object[] keyArgs); T Fetch<T>(string key, Func<T> callIfGetReturnsNull, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback, params object[] keyArgs); T Fetch<T>(string key, Action<T> callIfGetReturnsValue, Func<T> callIfGetReturnsNull, params object[] keyArgs); T Fetch<T>(string key, Action<T> callIfGetReturnsValue, Func<T> callIfGetReturnsNull, DateTime absoluteExpiration, params object[] keyArgs); T Fetch<T>(string key, Action<T> callIfGetReturnsValue, Func<T> callIfGetReturnsNull, TimeSpan slidingExpiration, params object[] keyArgs); T Fetch<T>(string key, Action<T> callIfGetReturnsValue, Func<T> callIfGetReturnsNull, CacheDependency dependencies, params object[] keyArgs); T Fetch<T>(string key, Action<T> callIfGetReturnsValue, Func<T> callIfGetReturnsNull, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, params object[] keyArgs); T Fetch<T>(string key, Action<T> callIfGetReturnsValue, Func<T> callIfGetReturnsNull, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback, params object[] keyArgs); void Insert(string key, object data, params object[] keyArgs); void Insert(string key, object data, DateTime absoluteExpiration, params object[] keyArgs); void Insert(string key, object data, TimeSpan slidingExpiration, params object[] keyArgs); void Insert(string key, object data, CacheDependency dependencies, params object[] keyArgs); void Insert(string key, object data, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, params object[] keyArgs); void Insert(string key, object data, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback, params object[] keyArgs); void Remove(string key, params object[] keyArgs); void RemoveAll(); int Count(); } |
Monday, August 23, 2010
Roll your own mocks with RealProxy
An article on writing your own mocking framework. This looks like a good side project to do at work....
NSubstitute - a friendly substitute for .NET mocking libraries
NSubstitute - a friendly substitute for .NET mocking libraries
http://nsubstitute.github.com/
Saturday, August 21, 2010
How to switch between HTTP and HTTPS in ASP.NET MVC2
[RequireHttps]
public ActionResult LogOn()
{
.....
}
Thursday, August 19, 2010
jQuery AJAX calls to a WCF REST Service - Rick Strahl's Web Log
Building JSON,XML REST API using WCF services
[ServiceContract]public interface IFetchChildItems{[OperationContract][WebInvoke(Method = "GET",ResponseFormat = WebMessageFormat,BodyStyle = WebMessageBodyStyle.Wrapped,UriTemplate = "{ID}/{Filter}")]void DoWork(int ID, string Filter);}
Integrated StructureMap container for the MvcServiceLocator in ASP.NET MVC 3 - Context is King
/// <summary>
/// Initializes a new instance of the <see cref="StructureMapControllerFactory"/> class.
/// </summary>
/// <param name="container">The container.</param>
public StructureMapControllerFactory(IContainer container)
: this(container, new DefaultControllerFactory())
{
}
Full-Text Search in ASP.NET using Lucene.NET
public void Application_OnStart(Object sender, EventArgs e)
{
if (btnet.Util.get_setting("EnableLucene", "1") == "1")
{
build_lucene_index(this.Application);
}
}
SubSonic3 Works on Mono! - Nathan Bridgewater
So a couple weeks ago I decided to test a few changes made to SubSonic3 that fixed a LINQ evaluation bug related to medium trust. Using a simple console app on linux/mono, I tested basic data access to a SQLite database using repository mode, and to my surprise it worked!
I've always been a big fan of SubSonic since its 2.0 version, which I used for a mid-sized e-commerce site. With a totally rewritten core, 3.0 uses LINQ (language integrated query) for all of its data access providing a great alternative to Dblinq for the Mono platform.
SubSonic3 supports ActiveRecord, Repository, and Custom Linq modes, which give you the flexibility to build code-first or database-first. SubSonic3 is not an ORM (object relational mapping) like NHibernate, but it can behave like one when you use Repository Mode using POCO (plain old CLR object) representations of your tables. SubSonic handles the mapping and database query generation itself based on the database provider configured. Its intention is to allow you to build code-first and let the persistence of the object be non-critical to your application. It can even migrate your class definition changes (table schema) to the database automatically during runtime; however, it still has the flexibility to let you design your database with keys, indexes, and constraints yourself without using the automatic migration. The SubSonic website has a great demo showing this capability.
Database Independence
To make SubSonc3 truly database agnostic, you have to use Repository mode. Active Record and Custom Linq modes DO support multiple database engines, but they all require custom class generation which is hard-wired to those engines. So when you change database types like from MySql to MSSQL or vice-versa, you have to regenerate your classes.
With Repository mode, you simply change your connection string in the app.config. It will use the 2.0 Data Provider model provided by the database engine client and the definition of your POCO classes to determine the SQL syntax and schema to use. SubSonic is pre-wired with MSSql, SQLite, MySql, and a generic ANSI Sql syntax support. There's been lots of talk about implementing Oracle and PostgreSql, which may already work in ActiveRecord or LinqTemplates, but are not yet in the Core assembly for use with Repository.
Decoupled – Mocking for Unit Tests and Framework Independence
Another big advantage of Repository is the ability to decouple your data framework from your application completely. Since the POCO objects are not directly tied to SubSonic, they can be re-used with other frameworks like NHibernate or the latest Entity Framework 4 without touching a single line of application code. It also opens the door to mocking and testability. Dependency Injection frameworks like Unity or StructureMap work perfect for this.
So how about a sample?
This is a silly little test application that is neither pretty nor elegant, but it proves that this code will run on Mono 2.6.3 and 2.7 (trunk) with a SQLite database. It also uses Unity for dependency injection much like you would in Asp.NET MVC. Within the project, you'll find an AppService interface used to provide the definition for simple 'business' functionality. This is meant to be generic for the sample; but in a real application, I would breakdown the services by functional purpose. They all can share the same LinqRepository data interface, which provides basic rules for LINQ-based CRUD. SubSonic3 hooks right into that and is nearly transparent to the application with the exception of a few attributes on the domain objects. There are some placeholder Mock classes there and sample mappings in the code just for show.
You can also get the latest version from IWS Snippets project subversion.
Multi-tenant ASP.NET – Foundation - Zack Owens
public interface IApplicationTenant{string ApplicationName { get; }IFeatureRegistry EnabledFeatures { get; }IEnumerable<string> UrlPaths { get; }IContainer DependencyContainer { get; }IViewEngine ViewEngine { get; }}
Wednesday, August 18, 2010
Project's Little Helper » Geek nights and user groups
As well as the geek night Oxford could soon have an agile based meetup. Take a look at Ed's post for more details.
A smashing idea.
http://projectslittlehelper.com/2010/being-agile/geek-nights-and-user-groups/
Sunday, August 15, 2010
NUnit isn't running VS10 code
I've downloaded the NUnit 2.5 source and opened the VS2008 solution in the VS2010 beta. Once the conversion finished I opened all the projects and changed the target framework setting for all the projects to ".NET Framework 4.0". I then built the solution without any errors. I can now use the NUnit GUI app to run tests built for .NET 4.0. I've not done exhaustive testing of this build so there may be problems, but for my purposes it works fine.
Update: It is not necessary to rebuild NUnit. I discovered that if you add the following to the relevant NUnit config file you can run a test dll built for .NET 4.0.
Under <configuration> add:
<startup> <requiredRuntime version="v4.0.20506" /></startup>and under <runtime> add:
<loadFromRemoteSources enabled="true" />
Saturday, August 14, 2010
Schedule a daily backup with SQL Server Express
At the moment I am finishing up an application that uses MS SQL Server Express 2008 as a data store for user data and MS SQL Server Express does not have an agent service you can use to automatically back up the database.
This article uses a similar technique to one I have been using to back up my development database.