Hi friends... i think i'm doing something wrong when registering services...
i have an object Bank. To persit Bank, i have an interface IDao<T> and its
implementation BaseDao<T>.
BaseDao<T> constructor is like:
public BaseDao(ISessionFactory factory)
And in its methods, i get NH Session like this:
return _factory.GetCurrentSession().Get<T>(id);
all that is in a separeted assembly. Now in my program i have a reference
for that assembly containing my Dao. For encapsulating
converstation, i have a BankCrud class. I use BankCrud from my Controller...
when i create BankCrud i got exception:
uNhAddins.sessionEasier.Conversations.ConversationException
{"No current conversation available. Create a conversation and bind it to
the container."}
BankCrud is decoreted correctly by [PersistenceConversational] and [
PersistenceConversation]
in my BankCrud i have the following field:
private IDao<Bank> bankDao = ServiceLocator.Current.GetInstance<IDao<Bank
>>();
my windsor setup is like this:
public class ServiceLocatorProvider
{
public static void Initialize()
{
var container = new WindsorContainer();
container.AddFacility<PersistenceConversationFacility>();
var nhConfigurator = new DefaultSessionFactoryConfigurationProvider();
nhConfigurator.AfterConfigure += ((sender, e) => new SchemaExport
(e.Configuration).Create(false, true));
var sfp = new SessionFactoryProvider(nhConfigurator);
container.Register(Component.For<ISessionFactoryProvider>().Instance(sfp));
container.Register(Component.For<ISessionWrapper>().ImplementedBy<
SessionWrapper>());
container.Register(Component.For<IConversationFactory>().ImplementedBy<
DefaultConversationFactory>());
container.Register(Component.For<IConversationsContainerAccessor
>().ImplementedBy<NhConversationsContainerAccessor>());
container.Register(Component.For<ISessionFactory>().Instance(sfp.GetFactory(
null)));
container.Register(
Component.For(typeof(IDao<>)).ImplementedBy(typeof(BaseDao
<>)).LifeStyle.Transient);
var sl = new WindsorServiceLocator(container);
container.Register(Component.For<IServiceLocator>().Instance(sl));
ServiceLocator.SetLocatorProvider(() => sl);
}
I dont know what is going on here... since i get my database structure
created correctly by SchemaExport defined on AfterConfigure event...
thanks for any help on this...
--
Paulo R. Quicoli
Editor Técnico - ClubeDelphi Magazine - DevMedia
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---