Managing WCF service instances

24 בנובמבר 2007

When you first time run your WCF service (http://localhost/myCoolService.svc) you get a nice tutorial, made by Microsoft, that explain you how you should use the service. This is not hard to notice that you should close every connection you made to a service. Like this:MyServiceClient client = new MyServiceClient(); client.Close(); I am using a lot of services in my apps and I don’t want to kip in mind that all the time I am using a service instance I have to remember to close the connection. So I wrote a simple code that handles the closing for me. public class ServicesFactory : IDisposable { ...
אין תגובות

Cache me if you can

22 בנובמבר 2007

  WCF provides nice capability of extending the behavior of operations by implementing IOperationBehavior interface. I want to concentrate on ApplyDispatchBehavior method of that interface, which purpose is to do extention to server side calls. I will show how I use this extensability to provide a nice and easy cache mechanisam. I will make a class which derives from Attribute class and implements an IOperationBehavior interface. Now I want to interfire in the invoke process of the method so I need to make another class that implements IOperationInvoker interface and would hold the cache logic. And...
תגיות: ,
3 תגובות

Caching with WCF

21 בנובמבר 2007

  Asp.Net provides us very powerful cache mechanism that can be found under System.Web.Caching. You can access the cache using the folioing syntax: HttpContext.Current.Cache = value; HttpContext.Current.Cache.Add(params...); Lately I was looking for similar mechanism to use with WCF. The flax ability of WCF services provide them to live in supported as well not supported web environment. In that case HttpContext.Current would not be available. From curiosity I went and check how the HttpContext.Current.Cache property is implemented and I was surprised to see the all it does is: return HttpRuntime.Cache. After googling I was more...
תגיות: ,
24 תגובות

Testable code – is it worth it?

17 בנובמבר 2007

  Recently I been refactoring some legasy code and writing a new one. I am using Rhino mocks to run my units and for that I have to write my code in a testable way. This approach makes my code looks not exactly the way I designed and want it to be. Eli Lopian wrote an article about this issue – "Stop Designing for Testability" and has some points to think of. In my opinion, if we have to write very simple code to encapsulate some internal logic for our base class and make sure that...
תגיות:
3 תגובות