S#arp 架构 - Rhino Security(未映射类:Rhino.Security.IUser)

发布于 2024-09-27 05:49:16 字数 3063 浏览 1 评论 0原文

我正在使用 S#arp Architecture 1.6 并已按照

Rhino Security - S#arp Architecture 实现了 Rhino Security 集成

我正在使用 Rhino.Commons 的最新版本。

我的 Application_EndRequest 方法包含

ISession session = NHibernateSession.Current;

我的 ComponentRegister.cs 包含

        container.Kernel.Register(

            Component.For<IAuthorizationService>()
                .ImplementedBy<AuthorizationService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IAuthorizationRepository>()
                .ImplementedBy<AuthorizationRepository>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IPermissionsBuilderService>()
                .ImplementedBy<PermissionsBuilderService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IPermissionsService>()
                .ImplementedBy<PermissionsService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IUnitOfWorkFactory>()
                .ImplementedBy<NHibernateUnitOfWorkFactory>()
                .LifeStyle.Is(LifestyleType.Singleton),
            Component.For<Rhino.Commons.IRepository<User>>()
                .ImplementedBy<NHRepository<User>>()
                .LifeStyle.Is(LifestyleType.Transient)
            );


        container.AddFacility<FactorySupportFacility>()
            .Register(Component.For<ISession>()
            .UsingFactoryMethod(() => NHibernateSession.Current)
            .LifeStyle.Is(LifestyleType.Transient)); 

我还按照说明添加了 RhinoSecurityPersistenceConfigurer()。

我在致电时收到的错误

UnitOfWork.Start() 

An association from the table Permissions refers to an unmapped class: Rhino.Security.IUser

有谁知道此错误的原因可能是什么?

有人成功将Rhino.Security 与S#arp 架构集成吗?

任何帮助都会很棒。

谢谢

Rich

-- 其他详细信息 --

感谢迄今为止的所有回复。

我仍然无法解决这个问题,所以我想添加更多细节。

在我的 Global.asax.cs 中,我有

private void InitializeNHibernateSession()
{
  NHibernateSession.Init(
    webSessionStorage,
    new string[] { Server.MapPath("~/bin/SwitchSnapshot.Data.dll") },
    new AutoPersistenceModelGenerator().Generate(),
    Server.MapPath("~/NHibernate.config"),
    null, null, new RhinoSecurityPersistenceConfigurer());
 }

RhinoSecurityPersistenceConfigurer :

public Configuration ConfigureProperties(Configuration nhibernateConfig)
{
  Security.Configure<User>(nhibernateConfig, SecurityTableStructure.Prefix);
  return nhibernateConfig;
}

我有一个 AuthorizationAttribute ,它调用

using (UnitOfWork.Start())

NHibernateUnitOfWorkFactory.cs 中发生的错误为

sessionFactory = cfg.BuildSessionFactory();

I'm using S#arp Architecture 1.6 and have implemented the Rhino Security integration as per

Rhino Security - S#arp Architecture

I'm using the latest build from Rhino.Commons

My Application_EndRequest method contains

ISession session = NHibernateSession.Current;

My ComponentRegister.cs contains

        container.Kernel.Register(

            Component.For<IAuthorizationService>()
                .ImplementedBy<AuthorizationService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IAuthorizationRepository>()
                .ImplementedBy<AuthorizationRepository>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IPermissionsBuilderService>()
                .ImplementedBy<PermissionsBuilderService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IPermissionsService>()
                .ImplementedBy<PermissionsService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IUnitOfWorkFactory>()
                .ImplementedBy<NHibernateUnitOfWorkFactory>()
                .LifeStyle.Is(LifestyleType.Singleton),
            Component.For<Rhino.Commons.IRepository<User>>()
                .ImplementedBy<NHRepository<User>>()
                .LifeStyle.Is(LifestyleType.Transient)
            );


        container.AddFacility<FactorySupportFacility>()
            .Register(Component.For<ISession>()
            .UsingFactoryMethod(() => NHibernateSession.Current)
            .LifeStyle.Is(LifestyleType.Transient)); 

I have also added RhinoSecurityPersistenceConfigurer() as per instructions.

The error I'm recieving on calling

UnitOfWork.Start() 

is

An association from the table Permissions refers to an unmapped class: Rhino.Security.IUser

Does anyone know what the cause of this error may be?

Has anyone successfully integrated Rhino.Security with S#arp Architecture?

Any help would be great.

Thanks

Rich

-- Additional Details --

Thanks for all the replies so far.

I've still not been able to resolve this, so thought I'd add more details.

In my Global.asax.cs I have

private void InitializeNHibernateSession()
{
  NHibernateSession.Init(
    webSessionStorage,
    new string[] { Server.MapPath("~/bin/SwitchSnapshot.Data.dll") },
    new AutoPersistenceModelGenerator().Generate(),
    Server.MapPath("~/NHibernate.config"),
    null, null, new RhinoSecurityPersistenceConfigurer());
 }

RhinoSecurityPersistenceConfigurer :

public Configuration ConfigureProperties(Configuration nhibernateConfig)
{
  Security.Configure<User>(nhibernateConfig, SecurityTableStructure.Prefix);
  return nhibernateConfig;
}

I have an AuthorizationAttribute which calls

using (UnitOfWork.Start())

The error is occuring in NHibernateUnitOfWorkFactory.cs as

sessionFactory = cfg.BuildSessionFactory();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

云之铃。 2024-10-04 05:49:16

您的 User 类(即实现 IUser 接口的类)需要一个 NHibernate 映射。您还需要数据库中的一个表,其中包含用户类的正确字段。

You need an NHibernate mapping for your User class (i.e. the class that implements the IUser interface). You also need a table in the database with the correct fields for your User class.

绮筵 2024-10-04 05:49:16

在创建 SessionFactory 之前,您必须让 RS 进行一些配置工作。请查看此处的第二期 http:// groups.google.com/group/sharp-architecture/browse_frm/thread/4093c52596f54d23/194f19cd08c8fdd7?q=#194f19cd08c8fdd7。它应该让你朝着正确的方向前进。

You have to let RS do some configuration work before the SessionFactory is created. Look at the second issue here http://groups.google.com/group/sharp-architecture/browse_frm/thread/4093c52596f54d23/194f19cd08c8fdd7?q=#194f19cd08c8fdd7. It should get you in the right direction.

琉璃繁缕 2024-10-04 05:49:16

感谢所有提供帮助的人。

到最后都是我自己的错。

我所需要做的就是遵循 S#arp 架构说明 好一点。

从旧版本的 S#arp 开始,我有 2 个配置文件 hibernate.cfg.xml 和 NHibernate.config。我以为我仍然需要两者,但我所需要的只是 S#arp 版本 1.6 的 hibernate.cfg.xml 和使用 Fluent NHibernate 映射的 User.cs。

我所做的其他更改是在 ComponentRegister.cs 中

        container.Kernel.Register( 
            Component.For<IAuthorizationService>()
                .ImplementedBy<AuthorizationService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IAuthorizationRepository>()
                .ImplementedBy<AuthorizationRepository>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IPermissionsBuilderService>()
                .ImplementedBy<PermissionsBuilderService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IPermissionsService>()
                .ImplementedBy<PermissionsService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IUnitOfWorkFactory>()
                .ImplementedBy<NHibernateUnitOfWorkFactory>()
                .LifeStyle.Is(LifestyleType.Singleton),
            Component.For<Rhino.Commons.IRepository<User>>()
                .ImplementedBy<NHRepository<User>>()
                .LifeStyle.Is(LifestyleType.Transient)
        );

        container.Kernel.AddFacility<FactorySupportFacility>()
            .Register(Component.For<ISession>()
            .UsingFactoryMethod(() => NHibernateSession.Current)
            .LifeStyle.Is(LifestyleType.Transient)
        ); 

然后在我的代码中使用以下内容。

        var authorizationService = IoC.Resolve<IAuthorizationService>();

        using (UnitOfWork.Start())
        {
        }

Thanks to all who helped out.

In the end it was my own fault.

All I needed to do was to follow the S#arp Architecture Instructions a little better.

From an old version of S#arp I had 2 config files hibernate.cfg.xml and NHibernate.config. I thought I still needed both, but all I needed was hibernate.cfg.xml for S#arp version 1.6 and mapped User.cs using Fluent NHibernate.

Other changes I did was in ComponentRegister.cs

        container.Kernel.Register( 
            Component.For<IAuthorizationService>()
                .ImplementedBy<AuthorizationService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IAuthorizationRepository>()
                .ImplementedBy<AuthorizationRepository>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IPermissionsBuilderService>()
                .ImplementedBy<PermissionsBuilderService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IPermissionsService>()
                .ImplementedBy<PermissionsService>()
                .LifeStyle.Is(LifestyleType.Transient),
            Component.For<IUnitOfWorkFactory>()
                .ImplementedBy<NHibernateUnitOfWorkFactory>()
                .LifeStyle.Is(LifestyleType.Singleton),
            Component.For<Rhino.Commons.IRepository<User>>()
                .ImplementedBy<NHRepository<User>>()
                .LifeStyle.Is(LifestyleType.Transient)
        );

        container.Kernel.AddFacility<FactorySupportFacility>()
            .Register(Component.For<ISession>()
            .UsingFactoryMethod(() => NHibernateSession.Current)
            .LifeStyle.Is(LifestyleType.Transient)
        ); 

Then use the following in my code.

        var authorizationService = IoC.Resolve<IAuthorizationService>();

        using (UnitOfWork.Start())
        {
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文