当前位置: 首页>>代码示例>>C#>>正文


C# IEntityPersister.GetConcreteProxyClass方法代码示例

本文整理汇总了C#中IEntityPersister.GetConcreteProxyClass方法的典型用法代码示例。如果您正苦于以下问题:C# IEntityPersister.GetConcreteProxyClass方法的具体用法?C# IEntityPersister.GetConcreteProxyClass怎么用?C# IEntityPersister.GetConcreteProxyClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEntityPersister的用法示例。


在下文中一共展示了IEntityPersister.GetConcreteProxyClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NarrowProxy

		/// <summary> 
		/// If the existing proxy is insufficiently "narrow" (derived), instantiate a new proxy
		/// and overwrite the registration of the old one. This breaks == and occurs only for
		/// "class" proxies rather than "interface" proxies. Also init the proxy to point to
		/// the given target implementation if necessary. 
		/// </summary>
		/// <param name="proxy">The proxy instance to be narrowed. </param>
		/// <param name="persister">The persister for the proxied entity. </param>
		/// <param name="key">The internal cache key for the proxied entity. </param>
		/// <param name="obj">(optional) the actual proxied entity instance. </param>
		/// <returns> An appropriately narrowed instance. </returns>
		public object NarrowProxy(INHibernateProxy proxy, IEntityPersister persister, EntityKey key, object obj)
		{
			bool alreadyNarrow = persister.GetConcreteProxyClass(session.EntityMode).IsAssignableFrom(proxy.GetType());

			if (!alreadyNarrow)
			{
				if (ProxyWarnLog.IsWarnEnabled)
				{
					ProxyWarnLog.Warn("Narrowing proxy to " + persister.GetConcreteProxyClass(session.EntityMode) + " - this operation breaks ==");
				}

				if (obj != null)
				{
					proxiesByKey.Remove(key);
					return obj; //return the proxied object
				}
				else
				{
					proxy = (INHibernateProxy)persister.CreateProxy(key.Identifier, session);
					proxiesByKey[key] = proxy; //overwrite old proxy
					return proxy;
				}
			}
			else
			{
				if (obj != null)
				{
					proxy.HibernateLazyInitializer.SetImplementation(obj);
				}
				return proxy;
			}
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:43,代码来源:StatefulPersistenceContext.cs


注:本文中的IEntityPersister.GetConcreteProxyClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。