Exemplo n.º 1
0
 public override INHibernateProxy GetProxy(object id, ISessionImplementor session)
 {
     try
     {
         var    initializer   = new DefaultLazyInitializer(EntityName, PersistentClass, id, GetIdentifierMethod, SetIdentifierMethod, ComponentIdType, session);
         object proxyInstance = IsClassProxy
                                     ? factory.CreateProxy(PersistentClass, initializer, Interfaces)
                                     : factory.CreateProxy(Interfaces[0], initializer, Interfaces);
         return((INHibernateProxy)proxyInstance);
     }
     catch (Exception ex)
     {
         throw new HibernateException("Creating a proxy instance failed", ex);
     }
 }
    public INHibernateProxy GetProxy(object id, ISessionImplementor session)
    {
        INHibernateProxy proxy;

        try
        {
            var initializer    = new  DefaultLazyInitializer(_entityName, _persistentClass, id, _getIdentifierMethod, _setIdentifierMethod, _componentIdType, session, _overridesEquals);
            var generatedProxy = (IProxy)Activator.CreateInstance(_proxyType);
            generatedProxy.Interceptor = initializer;
            proxy = (INHibernateProxy)generatedProxy;
        }
        catch (Exception e)
        {
            const string message = "Creating a proxy instance failed";
            _log.Error(message, e);
            throw new HibernateException(message, e);
        }

        return(proxy);
    }