Improvements

Feb 16, 2012 at 2:46 AM

Hi evol_hel,

How's the project development?

Today I had to customize your lib, and I'd like to shared the changes I made.

I changed the way you get the WCF attributes, now it gets the base classes and interfaces attributes too.

It solves this problem = http://rest.codeplex.com/discussions/253423

And I also created a new RoutedHandler called FactoryRouteHandler, because I needed to use a factory to instantiate my Service classes.

It is still kinda of crappy but I'm making some refactories.

 

If you are interested, I can show what I've done.

Feb 16, 2012 at 6:18 PM
Edited Feb 16, 2012 at 6:25 PM

I've made another improvement, I created a new RouteHandler, and it works this way:

public class CustomHandlerRoute<TContract> : RouteBase
{
...
    public CustomHandlerRoute(string routeUrl, Func<TContract> injectionMethod)
    {
...
}
...
}


So if I got the service contract

[ServiceContract]
public interface IService
{
    [WebGet]
    string Test();
}
and the implementation
public class Service : IService
{
    public string Test()
    {
        return "OK";
    }
}
I create a new route to this service this way

protected void Application_Start(object sender, EventArgs e)
{
    RouteTable.Routes.Add(new CustomHandlerRoute<IService>("Teste", () => new Service()));
}

My Service class does not inherit from RestHttpHandler... so you service project does not need to reference the RestCake library.
And I got control of how the service implementation gets instantiated.