Could you help me to make this works?
public interface IEntity { }
public abstract class EntityBase : IEntity {}
public class DocEntity : EntityBase { }
public interface IContext { }
public class Context : IContext { }
public interface IGridContext<TEntity>
: IContext where TEntity : IEntity { }
public class GridContext<TEntity>
: IGridContext<TEntity> where TEntity : IEntity { }
public interface IAction<in TContext> where TContext : IContext
{
void Exec(TContext context);
}
public class MyGridAction<TEntity>
: IAction<IGridContext<TEntity>> where TEntity : IEntity
{
public void Exec(IGridContext<TEntity> context)
{
throw new NotImplementedException();
}
}
Here's my installer:
public class ControllersInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container,
IConfigurationStore store)
{
container.Register(AllTypes.FromThisAssembly()
.BasedOn(typeof(IAction<>))
.WithService.AllInterfaces()
.Configure(c => c.LifeStyle.Transient));
}
}
Here is my test:
public class TestClass
{
private IWindsorContainer container;
[TestFixtureSetUp]
public void Init()
{
container = new WindsorContainer()
.Install(FromAssembly.This());
}
[Test]
public void TestMe()
{
var r1 =
container.ResolveAll<IAction<IGridContext<DocEntity>>>();
Assert.That(r1, Is.Not.Empty);
// Expect to see
IAction<IGridContext<DocEntity>> item =
new MyGridAction<DocEntity>();
// to use in this way: item.Exec(gridContext);
}
}
}--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/zDecwW3eFUsJ.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.