views:

8

answers:

0

I have a WCF service contract that reads like:

    [ServiceContract(Name = "DummyService") ]
    public interface IDummyService {

        [OperationContract]
        void DoSomething();

        [OperationContract(Name = "SayHello")]
        string SayHello(string message);
    }

The WCF service will be consumed by a Silverlight application. I'm finding a way to eliminate the need to manually write async contracts just so I can consume this through a proxy generated by ChannelFactory.

I'm thinking of writing a specialized invoker class. Sample usage is as follows:

// create the invoker using the endpoint config and the existing sync contract
var client = new ServiceInvoker<IDummyService>("LeyDummyService_Endpoint");

// invoke the desired service method set the callback, very similar to how 
// JQuery does AJAX calls...
client.Invoke(dummyService => dummyService.SayHello("harley"),
             (result) => MessageBox.Show(result));

Have anyone tried this? Is this even possible?