> you should explain me how NH should understand how use your ctor with
> parameter and how we can create a Proxy of your class.
If there is no default ctor and we do not need use IOC, as the last
(slow) alternative we can use FormatterServices.GetUninitializedObject
(type).
>Can you send an example
Sample:
public class Entity
{
private Guid key;
private string name;
public Entity(Guid key, string name)
{
this.key = key;
this.name = name;
}
public virtual Guid Key
{
get { return key; }
protected set { key = value; }
}
public virtual string Name
{
get { return name; }
protected set { name = value; }
}
}
>disable it <property name="use_proxy_validator">false</property>
This will cause to "delayed" runtime errors for lazy-entities with non-
virtual(non-interface) members.
>Probably the bytecode implemented inside the Framework Spring.NET has a
>different ProxyValidator.
No, they use NHibernate.Proxy.DynProxyTypeValidator.
On 23 ноя, 23:48, Fabio Maulo <[email protected]> wrote:
> 1) disable it <property name="use_proxy_validator">false</property>
>
> 2009/11/23 Nik Govorov <[email protected]>
>
>
>
>
>
> > Fabio, this is clear, but creating own factory is overhead(if I dont
> > want use any IOC).
> > In my ByteCodeProvider(exactly in
> > ReflectionOptimizer.CreateCreateInstanceMethod) I want to use:
> > return () => FormatterServices.GetUninitializedObject(type);
> > instead of :
> > ThrowExceptionForNoDefaultCtor(type);
> > and that works fine with linfu and spring proxies(but their factories
> > should have validator without checking default ctor).
> > Or I have something wrong?
> > Thank for reply.
>
> > On 23 ноя, 15:36, Fabio Maulo <[email protected]> wrote:
> > > If you don't like the ProxyValidator you can:
> > > 1) disable it <property name="use_proxy_validator">false</property>
> > > 2) override the bytecode provider
> > > <property
>
> > name="proxyfactory.factory_class">YourOwn.ByteCode.XYZ.ProxyFactoryFactory,
> > > YourOwn.ByteCode.XYZ</property>
> > > and provide your own validation.
>
> > > In order to use entities without default parameterless ctor:
> >http://fabiomaulo.blogspot.com/2008/11/entities-behavior-injection.html
>
> > > Part of that code now is available directly in Spring.NET+NH integration.
>
> > > 2009/11/22 Nik Govorov <[email protected]>
>
> > > > Hi.
> > > > I think that ProxyFactoryFactory(from NHibernate.ByteCode.LinFu and
> > > > NHibernate.ByteCode.Spring) should returns thier own implementations
> > > > of IProxyValidator without checking default constructor:
>
> > > > using CommonDynProxyTypeValidator =
> > > > NHibernate.Proxy.DynProxyTypeValidator;
>
> > > > namespace NHibernate.ByteCode.Castle
> > > > {
> > > > public class DynProxyTypeValidator : CommonDynProxyTypeValidator
> > > > {
> > > > protected override void CheckHasVisibleDefaultConstructor
> > > > (System.Type type)
> > > > {
>
> > > > }
> > > > }
> > > > }
> > > > Now, for using entities without default ctor(apart from implementing
> > > > BytecodeProvider), I have to disable proxy validation
> > > > (use_proxy_validator), but there are some other important checks in
> > > > DynProxyTypeValidator(also it's possible to create own
> > > > ProxyFactoryFactory basen on LinFu or Spring factory, but I dont like
> > > > this way).
> > > > Thanks.
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "nhusers" group.
> > > > To post to this group, send email to [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<nhusers%[email protected]
> > > > >
> > <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup
> > s.com>>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=.
>
> > > --
> > > Fabio Maulo
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]
> > >
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=.
>
> --
> Fabio Maulo
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.