Created
March 26, 2010 15:10
-
-
Save rauhryan/344997 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GetManufacturerAction | |
{ | |
public VendorModel<Manufacturer> Query(GetVendorRequest<Manufacturer> request) | |
{ | |
return new VendorModel<Manufacturer>(){ Vendor = request.Vendor }; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GetVendorRepresentativeAction | |
{ | |
public VendorModel<VendorRepresentative> Query(GetVendorRequest<VendorRepresentative> request) | |
{ | |
return new VendorModel<VendorRepresentative>(){ Vendor = request.Vendor }; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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