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 Offer<TProduct> : where TProduct : Product | |
{ | |
public string Id { get; set; } | |
public User Seller { get; set; } | |
public TProduct Product { get; set; } | |
public decimal Price { get; set; } | |
} | |
public class Product | |
{ | |
public string Id { get; set; } |
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 Product | |
{ | |
public int Id { get; set; } | |
public string Manufacturer { get; set; } | |
public string Name { get; set; } | |
} | |
public class Camera : Product | |
{ | |
public double Megapixels { get; set; } | |
} |
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 GenericActionInvoker : ControllerActionInvoker | |
{ | |
protected override async Task<IActionResult> InvokeActionAsync(ActionExecutingContext actionExecutingContext) | |
{ | |
var actionMethodInfo = _descriptor.MethodInfo; | |
//find action | |
if(actionExecutingContext.Controller.GetType().IsGenericType) | |
{ | |
var parameters = actionMethodInfo.GetParameters().Select(x => x.ParameterType).ToArray(); | |
actionMethodInfo = actionExecutingContext.Controller.GetType().GetMethod(actionMethodInfo.Name, parameters); |