NHibernate.ByteCode.Castle.ProxyFactory.GetProxy C# (CSharp) Method

GetProxy() public method

Build a proxy using the Castle.DynamicProxy library.
public GetProxy ( object id, ISessionImplementor session ) : INHibernateProxy
id object The value for the Id.
session ISessionImplementor The Session the proxy is in.
return INHibernateProxy
		public override INHibernateProxy GetProxy(object id, ISessionImplementor session)
		{
			try
			{
				var initializer = new LazyInitializer(EntityName, PersistentClass, id, GetIdentifierMethod,
				                                            SetIdentifierMethod, ComponentIdType, session);

				object generatedProxy = IsClassProxy
				                        	? ProxyGenerator.CreateClassProxy(PersistentClass, Interfaces, initializer)
				                        	: ProxyGenerator.CreateInterfaceProxyWithoutTarget(Interfaces[0], Interfaces,
				                        	                                                    initializer);

				initializer._constructed = true;
				return (INHibernateProxy) generatedProxy;
			}
			catch (Exception e)
			{
				log.Error("Creating a proxy instance failed", e);
				throw new HibernateException("Creating a proxy instance failed", e);
			}
		}