hm, what do you think of that:

        public abstract class ClassType : IUserType
        {
                private readonly Assembly assembly;

                protected ClassType(Assembly assembly)
                {
                        this.assembly = assembly;
                }

                public new bool Equals(object x, object y)
                {
                        if (ReferenceEquals(x, y)) return true;
                        if (x == null || y == null) return false;
                        return x.Equals(y);

                }

                public int GetHashCode(object x)
                {
                        return x == null ? assembly.GetHashCode() : 
x.GetHashCode();
                }

                public object NullSafeGet(IDataReader rs, string[] names, 
object owner)
                {
                        var obj = NHibernateUtil.String.NullSafeGet(rs, 
names[0]);
                        if (obj == null) return null;
                        var result =  
Activator.CreateInstance(assembly.FullName, obj.ToString());
                        return result;
                }

                public void NullSafeSet(IDbCommand cmd, object value, int index)
                {
                        if (value == null)
                                ((IDataParameter) cmd.Parameters[index]).Value 
= DBNull.Value;
                        else
                        {
                                var typeName = value.GetType().Name;
                                ((IDataParameter) cmd.Parameters[index]).Value 
= typeName;
                        }
                }

                public object DeepCopy(object value)
                {
                        return value;
                }

                public object Replace(object original, object target, object 
owner)
                {
                        return original;
                }

                public object Assemble(object cached, object owner)
                {
                        return cached;
                }

                public object Disassemble(object value)
                {
                        return value;
                }

                public SqlType[] SqlTypes
                {
                        get { return new[] { NHibernateUtil.String.SqlType }; }
                }

                public Type ReturnedType
                {
                        get { return typeof(object); }
                }

                public bool IsMutable
                {
                        get { return false; }
                }
        }

I wonder if the object return type could have any side effects...
"inspired" by 
http://www.lostechies.com/blogs/rhouston/archive/2008/03/23/mapping-strings-to-booleans-using-nhibernate-s-iusertype.aspx
the only info I did find. But I'll gibe nh in action a try, when @
home.

cheers,

jan

On Thu, Nov 20, 2008 at 8:11 PM, Tuna Toksöz <[EMAIL PROTECTED]> wrote:
> So yes, go for CreditCardType:IUserType and discriminate them on your own?
>
> On Fri, Nov 21, 2008 at 12:09 AM, Jan Limpens <[EMAIL PROTECTED]> wrote:
>>
>> string, it should simply give me back an instance of that type. Isn't
>> this somehow doable with the existing infra, its really not that
>
>
> --
> Tuna Toksöz
> http://www.tunatoksoz.com
>
> Typos included to enhance the readers attention!
>
>
> >
>



-- 
Jan
___________________
[EMAIL PROTECTED]
www.limpens.com
+55 (11) 3082-1087
+55 (11) 3097-8339

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to