How can I register a generic object factory?
问题 I have the following two classes: public class KeyedEntity<TEntity> { internal KeyedEntity() { } public Identifier Key { get; set; } public TEntity Entity { get; set; } } public static class KeyedEntity { public static KeyedEntity<TEntity> Create<TEntity>(Identifier key, TEntity entity) { return new KeyedEntity<TEntity> { Key = key, Entity = entity, }; } } The reason the constructor is internal and the second class exists is I want to enforce the more highly-maintainable KeyedEntity.Create(x,