Posts

ECO and distributed transactions

My current app is a website, each client gets their own unique database in order to help prevent possible data access from other clients (and meet various legal requirements too.)  One of the features of this application is that there is some core data (such as countries/currencies) which is maintained on behalf of the client.  This data will be identical for all clients, and only maintained by a system administrator. Obviously expecting the admin to log into each client to perform updates is unreasonable, so I have structured my app so that there is a separate Admin website which updates a master database and propagates the changes to all of the clients. When the master website does an update it performs it within an IUnitOfWork, and then tells the same update command to execute for each client database too.  If any of these updates fail for whatever reason then the whole thing needs to be cancelled whether one of the child databases updated or not. using (var distributedTransac

Tightly coupling generic types

Update : Instead of decorating responses with IResponseFor<T> I now instead decorate the command/query with IExpectResponse<T> - Each command/query should only have one response type, and this way it makes it possible to specify the return type should be something simple like a GUID. My server application works purely on a request/response pattern, like so var query = new GetCustomerQuery(customerUniqueID); var response = AppServer.Execute < GetCustomerQuery , GetCustomerQueryResponse > (query); What I wanted to avoid though was the possibility that the user (me writing the client app) would do something silly like the following code and use the wrong pair combination var query = new GetCustomerQuery(customerUniqueID); var response = AppServer.Execute < GetCustomerQuery , GetEmployeeQueryResponse > (query); Up until now I had the server interface defined like this, so that I can at least ensure the generic parameters are a Query and R

ECO Persistence Mapper per connection

The Enterprise Core Objects Persistence Mapper is a singleton which is used by all EcoSpace instances.  It’s purpose is to load mapping information from the DB when your app starts and to cache it, improving performance. I needed a connection per client, all running within a single application.  This was a problem because once the PMP is created its connection string is tied to a single database.  So I had to come up with a new PersistenceMapperDynamicSharer component.  It is used on the EcoSpace to specify the PMapper type; additionally you can specify a connection string to use. It works by dynamically creating a descendant class of your PersistenceMapperProvider at runtime, one for each connection string. public class PersistenceMapperDynamicSharer : PersistenceMapperSharer { static ReaderWriterLockSlim Locker = new ReaderWriterLockSlim(); static Dictionary < string , PersistenceMapperProvider > MapperProviders = new Dictionary < string , PersistenceMapperPr

PropertyChangedEventHandler is not marked as serializable

My data-transfer-objects implement INotifyPropertyChanged, which was giving me a problem whenever I tried to serialise them over a Remoting session.  If you try to add [NonSerialized] to the event you get an error informing you that you can only apply this attribute to fields, and not properties. The solution is pretty simple, I think the .NET compiler should do this by default. [NonSerialized] PropertyChangedEventHandler propertyChanged; public event PropertyChangedEventHandler PropertyChanged { add { propertyChanged += value; } remove { propertyChanged -= value; } }

Partial declarations of must not specify different base classes

I wanted to use a common base class for a set of UserControls in my WPF application, but when I changed the class’s ancestor in the code file and compiled I would get the error “Partial declarations of must not specify different base classes” This is because when you compile a WPF application Visual Studio generates a partial class in a code-behind file automatically, the base type specified is always “UserControl”.  To solve this problem change your XAML from this   < UserControl x:Class ="MyApp.MyControl" /> To this < local:SomeBaseTypeYouWantToUse x:Class ="MyApp.MyControl" xmlns:local ="clr-namespace:NameSpace.To.Your.BaseClass" />

A WebServer for MonoTouch that also parses posted form data (HttpListenerRequest)

I found a few examples of web servers for MonoTouch but none of them parsed the data sent in a POST request.  I looked around the web and was unable to find any examples of how to achieve this.  So now that I’ve written it myself I’ve decided to share my own implementation.  This includes not only the code for processing the form post data but also for registering request handlers etc. Here is an example of how you would use the web server public BookUploadViewController() : base ( " BookUploadViewController " , null ) { RequestHandler = new DefaultRequestHandler(); var defaultActionHandlerFactory = new DefaultActionHandlerFactory(); RegisterActionHandlers(defaultActionHandlerFactory); RequestHandler.AddActionHandlerFactory(defaultActionHandlerFactory); WebServer = new EmbeddedWebServer(RequestHandler); } void RegisterActionHandlers(DefaultActionHandlerFactory factory) { fact

Embarcadero should revive Bold for Delphi

I've recently been doing some work on a Bold for Delphi application. I am really quite surprised how much I am still impressed with this framework, it really was (and still is) so much ahead of its time. Embarcadero really should revive this product and put it back into Delphi. They could make it a free addition to Delphi, or maybe even ship it with Delphi as an open source project. Embarcadero! You have a great tool here, don't hide it away, use it!