Skip to content

Instantly share code, notes, and snippets.

@rauhryan
Created March 26, 2010 15:10
Show Gist options
  • Save rauhryan/344997 to your computer and use it in GitHub Desktop.
Save rauhryan/344997 to your computer and use it in GitHub Desktop.
public class GetManufacturerAction
{
public VendorModel<Manufacturer> Query(GetVendorRequest<Manufacturer> request)
{
return new VendorModel<Manufacturer>(){ Vendor = request.Vendor };
}
}
public class GetVendorRepresentativeAction
{
public VendorModel<VendorRepresentative> Query(GetVendorRequest<VendorRepresentative> request)
{
return new VendorModel<VendorRepresentative>(){ Vendor = request.Vendor };
}
}
public class RedirectToVendorAction
{
private readonly IVendorService _vendorService;
public RedirectToVendorAction(IVendorService vendorService)
{
_vendorService = vendorService;
}
public FubuContinuation Query(GetVendorRequest<Vendor> request)
{
var vendor = _vendorService.GetVendorById(request.Id);
var returnType = typeof(GetVendorRequest<>).MakeGenericType(vendor.GetType());
var returnModel = Activator.CreateInstance(returnType, new object[] { request.Id, vendor });
return FubuContinuation.TransferTo(returnModel);
}
}
public class VendorModel<T>
{
public T Vendor { get; set; }
}
public class GetVendorRequest<T> : IRequestById
{
public GetVendorRequest()
{
}
public GetVendorRequest(Guid id, T vendor)
{
Id = id;
Vendor = vendor;
}
public Guid Id { get; set; }
public T Vendor { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment