public static T GetOne(Guid Id, Connection con, Guid VirtualLoadBalancerId) { try { IBaseServiceInterface <T> service = (IBaseServiceInterface <T>)Activator.CreateInstance(typeof(Y), new object[] { con, VirtualLoadBalancerId }); Task <Result <T> > callTask = Task.Run(() => service.GetAsync(Id)); callTask.Wait(); var job = callTask.Result.Object; return(job); } catch (Exception e) { throw new RemoteException("An API Error has happen"); } }
public static T GetOne(Guid Id, Connection con) { IBaseServiceInterface <T> service = (IBaseServiceInterface <T>)Activator.CreateInstance(typeof(Y), new object[] { con }); Task <Result <T> > callTask = Task.Run(() => service.GetAsync(Id)); callTask.Wait(); var result = callTask.Result; if (result.Object != null) { return(result.Object); } else if (result.Error != null) { throw new RemoteException("Conflict Error: " + result.Error.ErrorType + "\r\n" + result.Error.FaultyValues); } else { throw new RemoteException("API returns: " + result.Code.ToString()); } }