gpt4 book ai didi

C# 动态代理

转载 作者:行者123 更新时间:2023-11-30 22:46:13 25 4
gpt4 key购买 nike

C#中如何判断一个对象是原始对象还是原始对象的动态代理?

我遇到了使用 nhibernate 的需要。

最佳答案

答案在 previous question.

You can detect if a class is a NHibernate proxy by casting it to (unsurprisingly) INHibernateProxy.

If you need to get the underlying "real" object, use:

Session.GetSessionImplementation().PersistenceContext.Unproxy(proxiedObject) You don't need to test for proxies to call Unproxy; it returns the original parameter if it's not a proxy.

关于C# 动态代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2739060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com