public async Task <IList <IObject> > Get() { try { ServiceHelperModel serviceHelperModel = new ServiceHelperModel { Endpoint = "fabric:/SystemPattern/SystemPattern.ProductCatalog", methodName = "GetAllProducts" }; var allP = await _service.InvokeService(serviceHelperModel); return(allP); } catch (Exception ex) { throw; } }
public async Task <IList <IObject> > InvokeService(ServiceHelperModel serviceModel) { string uri = serviceModel.Endpoint; string method = "IProductCatalogService." + serviceModel.methodName; var _catalogService = ServiceProxy.Create <IProductCatalogService>( new Uri(uri), new ServicePartitionKey(0)); var methodInfo = _catalogService.GetType().GetRuntimeMethods().Where(m => m.Name == method).FirstOrDefault(); var resultTask = (Task)methodInfo.Invoke(_catalogService, null); await resultTask.ConfigureAwait(false); var res = resultTask.GetType().GetProperty("Result"); var resValue = (IList <IObject>)res.GetValue(resultTask); return(resValue); }