castle-windsor

Should controller lifestyle always be transient in Windsor configuration for ASP.NET MVC?

感情迁移 提交于 2021-02-18 12:22:31
问题 I ran into a problem where I had an Html.DropDownList in my view that would postback the selected value the first time I submitted the form, but each subsequent postback would only post data from the initial postback. So I added lifestyle="transient" to the component element where I had configured my controller for castle windsor, which fixed the problem, but of course made postbacks take longer since a new controller was being instantiated per request. Given the information above, what

Registering a generic abstract class in Castle Windsor

十年热恋 提交于 2020-12-04 08:14:22
问题 I am trying to register a type by convention, I've simplified my case in this example: public abstract class BaseEntity{} public class EntityA : BaseEntity{} public class EntityB : BaseEntity{} public abstract class BaseClass { //... } public abstract class GenericBaseClass<T> : BaseClass where T : BaseEntity { //.. } public class ConcreteA : GenericBaseClass<EntityA> { //... } public class ConcreteB : GenericBaseClass<EntityB> { //... } I'm trying to find the way to register GenericBaseClass

Registering a generic abstract class in Castle Windsor

百般思念 提交于 2020-12-04 08:14:03
问题 I am trying to register a type by convention, I've simplified my case in this example: public abstract class BaseEntity{} public class EntityA : BaseEntity{} public class EntityB : BaseEntity{} public abstract class BaseClass { //... } public abstract class GenericBaseClass<T> : BaseClass where T : BaseEntity { //.. } public class ConcreteA : GenericBaseClass<EntityA> { //... } public class ConcreteB : GenericBaseClass<EntityB> { //... } I'm trying to find the way to register GenericBaseClass

Autofac register assembly types

南楼画角 提交于 2020-05-09 20:34:37
问题 In Castle, I used to do the following to register types from a different assembly: Classes.FromAssemblyNamed("MyServer.DAL") .Where(type => type.Name.EndsWith("Repository")) .WithServiceAllInterfaces() .LifestylePerWebRequest(), In Autofac, I change the above code to this: builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies()) .Where(t => t.Name.EndsWith("Repository")) .InstancePerRequest(); Is it correct? 回答1: This is the correct way: builder.RegisterAssemblyTypes(AppDomain

Configure windsor interceptor to hook only marked methods

筅森魡賤 提交于 2020-02-05 05:15:16
问题 Is there possibility to configure Interceptor to hook methods only of special interface, or by base class? Currently I have registered Interceptor that works with scope of connections to one DB. Now I added another scope working with another db and want to add another interceptor, which will hook methods of second scope. It is possible to configure interceptor via xml files, instead of checking target of invocation properties. I've added interceptor via components: <component type="Common.IoC