Created
October 16, 2011 03:01
-
-
Save jmarnold/1290451 to your computer and use it in GitHub Desktop.
Action Discovery
This file contains hidden or 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 CreateEntityAction<TEntity> | |
where TEntity : IDomainEntity | |
{ | |
public CommandResult<TEntity> Execute(CreateEntityModel<TEntity> input) | |
{ | |
// do generic stuff | |
} | |
} |
This file contains hidden or 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 CreateEntityActionSource : IActionSource | |
{ | |
public IEnumerable<ActionCall> FindActions(TypePool types) | |
{ | |
var entities = // get the types from a scan or something conventional | |
entities | |
.Select(entity => { | |
var handlerType = typeof(CreateEntityAction<>).MakeGenericType(entity); | |
return new ActionCall(handlerType, handlerType.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance)); | |
}); | |
} | |
} |
This file contains hidden or 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 interface IActionSource | |
{ | |
IEnumerable<ActionCall> FindActions(TypePool types); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment