castle

Persisting a Castle DynamicProxy that's not associated with a NH Session

我的梦境 提交于 2019-12-13 04:48:21
问题 My session uses an NHInterceptor to add INotifyPropertyChanged support to models. // I use the session generated here to fetch Data public class SessionServiceImpl : ISessionService { [Inject] public ISessionFactory SessionFactory { get; set; } [Inject] public NhChangeNotificationInterceptorImpl ChangeNotificationInterceptor { get; set; } public ISession GetSession() // reduced code here { return SessionFactory.OpenSession(ChangeNotificationInterceptor); } } // This is the interceptor

Specifying Castle WCF Integration Facility Endpoint Behavior per Endpoint

隐身守侯 提交于 2019-12-12 20:12:43
问题 I'm using Castle WCF Integration Facility and I have everything working properly for my first webHttp endpoint. For this endpoint to work, it requires that the endpoint have the WebHttpBehavior enabled. I was able to achieve this using: container.Register(Component.For<IEndpointBehavior>() .ImplementedBy<WebHttpBehavior>()); This becomes a problem when I try to enable a second endpoint using BasicHttpBinding which is not compatible with the WebHttpBehavior. Is there someway to specify that

How to resolve Castle.Windsor and MoQ version conflicts for Castle.Core assembly

99封情书 提交于 2019-12-12 18:33:24
问题 In my project I need to use simultaneously Castle.Windsor and Moq dlls. Windsor requires Castle.Core also to be referenced in the project. Problem starts when I try to use methods from Castle.Core: Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(...); Problem1: If I use Moq.dll from NET40 folder, I got built error "The type 'Castle.DynamicProxy.Generators.AttributesToAvoidReplicating' exists in both '...\Windsor\dotNet40\Castle.Core.dll' and '...\MoQ\NET40\Moq.dll'" Problem2:

Medium trust share webhosting site with Castle Windsor

风格不统一 提交于 2019-12-12 16:26:06
问题 I deployed by ASP.NET MVC 3 applications which uses Castle Windsor for DI. The application is hosted on GoDaddy's shared web hosting. I am receiving the following exception when trying to load the site. Doing some search on Google, I found that it's caused because GoDaddy hosting is medium trust. Is there any ways to solve this problem? Inheritance security rules violated while overriding member: 'Castle.MicroKernel.DefaultKernel.InitializeLifetimeService()'. Security accessibility of the

castle IOC - resolving circular references

本秂侑毒 提交于 2019-12-12 13:45:41
问题 quick question for my MVP implementation: currently I have the code below, in which both the presenter and view are resolved via the container. Then the presenter calls View.Init to pass himself to the view. I was wondering however if there is a way to let the container fix my circular reference (view -> presenter, presenter -> view). class Presenter : IPresenter { private View _view; public Presenter(IView view, ...){ _view = view; _view.Init(this) } } class View : IView { private IPresenter

Self-proxying constructor with Castle?

╄→гoц情女王★ 提交于 2019-12-12 05:13:12
问题 Is it possible for a class's constructor to wrap a proxy around itself? This code, unfortunately, causes a StackOverflowException. void Main() { var thing = new Thing(); } public static readonly ProxyGenerator generator = new ProxyGenerator(); public class Thing { public Thing() { generator.CreateClassProxyWithTarget(this); } } I want some way to guarantee that new instances of my class are wrapped in the proxy instead of having to create some kind of factory that creates proxied instance.

Castle Windsor 3 + Fluent NHibernate + Castle.NHibernate.Integration

蹲街弑〆低调 提交于 2019-12-11 01:39:19
问题 I have created a sample project to replicate an issue I'm having with Castle Windsor and the NHibernate Integration Facility. I get the following exception: Method not found: 'Void Castle.Core.DependencyModel..ctor(Castle.Core.DependencyType, System.String, System.Type, Boolean)'. With the following stack-trace: at Castle.Facilities.NHibernateIntegration.Internal.NHSessionComponentInspector.ProcessModel(IKernel kernel, ComponentModel model) at Castle.MicroKernel.ModelBuilder

How are components removed with Castle 3.0?

蹲街弑〆低调 提交于 2019-12-10 13:05:20
问题 I have IWindsorContaner which exists for the whole application lifetime. For Unittests it is possible to register mocks/stubs, etc. under their Type. When the test is finished and the fixture is disposed the registered components in forthe test are remove with a self created method called "Unregister". Now, I want to update to the latest Castle version which is 3.0. According to the 3.0 release notes something like public void Unregister(string contextName, string registrationName) {

Passing parameters to UsingFactoryMethod in Castle Windsor

霸气de小男生 提交于 2019-12-10 09:56:46
问题 How do I pass dynamic parameters to a UsingFactoryMethod registration? For example, I want to write something like: container.Register( Component.For<IFoo>() .UsingFactoryMethod(return DoSomethingAndReturnInstance(paremeter))); I need the parameters to be sent at runtime, like this: container.Resolve<IFoo>(new { parameter = value }); How can it be done? 回答1: CreationContext.AdditionalParameters has the values you pass to Resolve 回答2: You just have to use container.Register( Component.For<IFoo

WPF + Castle Windsor + MVVM: Locator-DataContext

前提是你 提交于 2019-12-09 23:55:26
问题 Edit: I have found one method to do this but I'm not sure if it is the best way. In WindsorContainer initialization, first I register viewmodel: container.Register(Component.For<CentrosViewModel>().LifeStyle.Transient); and later I register the View container.Register(Component.For<CentrosAdminView>().LifeStyle.Transient.DependsOn(Property.ForKey("DataContext") .Eq(ViewModelLocator.Centrosviewmodel))); And definition of property ViewModelLocator.Centrosviewmodel is: public static CentrosModel