From: Michael D. <mik...@us...> - 2004-06-03 14:29:09
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13459 Modified Files: Master.cs MultiplicityType.cs NestingComponent.cs NHibernate.DomainModel-1.1.csproj Added Files: INameable.cs Location.cs Many.cs Middle.cs MiddleKey.cs Mono.cs Multi.cs One.cs Outer.cs OuterKey.cs Log Message: Continued to add Domain Classes for test fixtures. --- NEW FILE: MiddleKey.cs --- using System; namespace NHibernate.DomainModel { /// <summary> /// Summary description for MiddleKey. /// </summary> [Serializable] public class MiddleKey { private Inner _sup; private string _two; private string _one; public Inner Sup { get { return _sup; } set { _sup = value; } } public string One { get { return _one; } set { _one = value; } } public string Two { get { return _two; } set { _two = value; } } #region System.Object Members public override bool Equals(object obj) { if(this==obj) return true; MiddleKey cidMasterID = obj as MiddleKey; if(cidMasterID==null) return false; if ( _one!=null ? !_one.Equals(cidMasterID.One) : cidMasterID.One!=null) return false; if ( _sup!=null ? !_sup.Equals(cidMasterID.Sup) : cidMasterID.Sup!=null) return false; if ( _two!=null ? !_two.Equals(cidMasterID.Two) : cidMasterID.Two!=null) return false; return true; } public override int GetHashCode() { unchecked { int result; //TODO: string can't be null result = ( _sup!=null ? _sup.GetHashCode() : 0 ); result = 29 * result + ( _one!=null ? _one.GetHashCode() : 0 ); result = 29 * result + ( _two!=null ? _two.GetHashCode() : 0 ); return result; } } #endregion } } --- NEW FILE: Location.cs --- using System; namespace NHibernate.DomainModel { /// <summary> /// Summary description for Location. /// </summary> [Serializable] public class Location { private int _streetNumber; private string _city; private string _streetName; private string _countryCode; // private Locale _locale; TODO: how to do this in .net?? private string _description; public int StreetNumber { get { return _streetNumber; } set { _streetNumber = value; } } public string City { get { return _city; } set { _city = value; } } public string StreetName { get { return _streetName; } set { _streetName = value; } } public string CountryCode { get { return _countryCode; } set { _countryCode = value; } } public string Description { get { return _description; } set { _description = value; } } #region System.Object Members public override bool Equals(object obj) { if(this==obj) return true; Location rhs = obj as Location; if(rhs==null) return false; return ( rhs.City.Equals(this.City) && rhs.StreetName.Equals(this.StreetName) && rhs.CountryCode.Equals(this.CountryCode) && rhs.StreetNumber.Equals(this.StreetNumber) ); } public override int GetHashCode() { return _streetName.GetHashCode(); } #endregion } } --- NEW FILE: One.cs --- using System; using System.Collections; namespace NHibernate.DomainModel { /// <summary> /// Summary description for One. /// </summary> public class One { private long _key; private string _value; // <set> mapping private IDictionary _manies; private int _x; public long Key { get { return _key; } set { _key = value; } } public string Value { get { return _value; } set { _value = value; } } public IDictionary Manies { get { return _manies; } set { _manies = value; } } public int X { get { return _x; } set { _x = value; } } } } Index: NHibernate.DomainModel-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHibernate.DomainModel-1.1.csproj,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** NHibernate.DomainModel-1.1.csproj 3 Jun 2004 13:31:52 -0000 1.14 --- NHibernate.DomainModel-1.1.csproj 3 Jun 2004 14:29:00 -0000 1.15 *************** *** 360,363 **** --- 360,368 ---- /> <File + RelPath = "INameable.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "INamed.cs" SubType = "Code" *************** *** 394,401 **** --- 399,416 ---- /> <File + RelPath = "Location.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Location.hbm.xml" BuildAction = "EmbeddedResource" /> <File + RelPath = "Many.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Many.hbm.xml" BuildAction = "EmbeddedResource" *************** *** 407,410 **** --- 422,440 ---- /> <File + RelPath = "Middle.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "MiddleKey.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Mono.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "MoreStuff.cs" SubType = "Code" *************** *** 412,415 **** --- 442,450 ---- /> <File + RelPath = "Multi.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Multiplicity.cs" SubType = "Code" *************** *** 440,447 **** --- 475,497 ---- /> <File + RelPath = "One.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "One.hbm.xml" BuildAction = "EmbeddedResource" /> <File + RelPath = "Outer.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "OuterKey.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Parent.cs" SubType = "Code" Index: NestingComponent.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NestingComponent.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NestingComponent.cs 2 Jun 2004 04:53:24 -0000 1.2 --- NestingComponent.cs 3 Jun 2004 14:29:00 -0000 1.3 *************** *** 4,8 **** namespace NHibernate.DomainModel { ! [Serializable] public class NestingComponent { /// <summary> /// Holds the _nested --- 4,8 ---- namespace NHibernate.DomainModel { ! [Serializable] public class NestingComponent { /// <summary> /// Holds the _nested *************** *** 15,25 **** public ComponentCollection Nested { ! get ! { ! return _nested; ! } ! set ! { ! _nested = value; ! } } } } \ No newline at end of file --- 15,19 ---- public ComponentCollection Nested { ! get { return _nested; } ! set { _nested = value; } } } } \ No newline at end of file --- NEW FILE: INameable.cs --- using System; namespace NHibernate.DomainModel { /// <summary> /// Summary description for INameable. /// </summary> public interface INameable { string Name { get; set; } long Key { get; set; } } } --- NEW FILE: Mono.cs --- using System; using System.Collections; namespace NHibernate.DomainModel { /// <summary> /// Summary description for Mono. /// </summary> public class Mono : Simple { private IDictionary _strings; public Mono() : base() {} public Mono(int c) : base(c) {} public IDictionary Strings { get { return _strings; } set { _strings = value; } } } } --- NEW FILE: Multi.cs --- using System; namespace NHibernate.DomainModel { /// <summary> /// Summary description for Multi. /// </summary> public class Multi : Simple { private string _extraProp; private Multi.Component _comp; private Po _po; public Multi() : base() {} public string ExtraProp { get { return _extraProp; } set { _extraProp = value; } } public Multi.Component Comp { get { return _comp; } set { _comp = value; } } public Po Po { get { return _po; } set { _po = value; } } public sealed class Component { //TODO: is java Calendar -> .net DateTime an appropriate conversion private DateTime _cal; private float _floaty; public DateTime Cal { get { return _cal; } set { _cal = value; } } public float Floaty { get { return _floaty; } set { _floaty = value; } } } } } --- NEW FILE: Many.cs --- using System; namespace NHibernate.DomainModel { /// <summary> /// Summary description for Many. /// </summary> public class Many { private long _key; private One _one; private int _x; public long Key { get { return _key; } set { _key = value; } } public One One { get { return _one; } set { _one = value; } } public int X { get { return _x; } set { _x = value; } } } } --- NEW FILE: OuterKey.cs --- using System; namespace NHibernate.DomainModel { /// <summary> /// Summary description for OuterKey. /// </summary> [Serializable] public class OuterKey { private Middle _master; private string _detailId; public Middle Master { get { return _master; } set { _master = value; } } public string DetailId { get { return _detailId; } set { _detailId = value; } } #region System.Object Members public override bool Equals(object obj) { if(this==obj) return true; OuterKey cidDetailId = obj as OuterKey; if(cidDetailId==null) return false; if(_detailId!=null ? !_detailId.Equals(cidDetailId.DetailId) : cidDetailId.DetailId!=null) return false; if(_master!=null ? !_master.Equals(cidDetailId.Master) : cidDetailId.Master!=null) return false; return true; } public override int GetHashCode() { unchecked { int result; result = ( _master!=null ? _master.GetHashCode() : 0 ); //TODO: string == null??? result = 29 * result + ( _detailId!=null ? _detailId.GetHashCode() : 0 ); return result; } } #endregion } } --- NEW FILE: Outer.cs --- using System; namespace NHibernate.DomainModel { /// <summary> /// Summary description for Outer. /// </summary> [Serializable] public class Outer { private OuterKey _id; private string _bubu; public OuterKey Id { get { return _id; } set { _id = value; } } public string Bubu { get { return _bubu; } set { _bubu = value; } } #region System.Object Members public override bool Equals(object obj) { if(this==obj) return true; Outer rhs = obj as Outer; if(rhs==null) return false; if( _id!=null ? !_id.Equals(rhs.Id) : rhs.Id!=null ) return false; return true; } public override int GetHashCode() { return ( _id!=null ? _id.GetHashCode() : 0 ); } #endregion } } Index: MultiplicityType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/MultiplicityType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MultiplicityType.cs 9 Apr 2004 13:14:53 -0000 1.1 --- MultiplicityType.cs 3 Jun 2004 14:29:00 -0000 1.2 *************** *** 4,18 **** namespace NHibernate.DomainModel { - public class MultiplicityType : ICompositeUserType ! { private static string[] PROP_NAMES = new String[] { "count", "glarch" }; private static Type.IType[] TYPES = new Type.IType[] { NHibernate.Int32, NHibernate.GetSerializable(typeof(Glarch)) }; public String[] PropertyNames { ! get ! { return PROP_NAMES; } } public Type.IType[] PropertyTypes { ! get ! { ! return TYPES; ! } } public object GetPropertyValue(object component, int property) { Multiplicity o = (Multiplicity) component; return property==0 ? (object)o.count : (object)o.glarch; } public void SetPropertyValue(object component, int property, object value) { Multiplicity o = (Multiplicity) component; if (property==0) --- 4,13 ---- namespace NHibernate.DomainModel { public class MultiplicityType : ICompositeUserType ! { private static readonly string[] PROP_NAMES = new String[] { "count", "glarch" }; private static readonly Type.IType[] TYPES = new Type.IType[] { NHibernate.Int32, NHibernate.Entity(typeof(Glarch)) }; public String[] PropertyNames { ! get { return PROP_NAMES; } } public Type.IType[] PropertyTypes { ! get { return TYPES; } } public object GetPropertyValue(object component, int property) { Multiplicity o = (Multiplicity) component; return property==0 ? (object)o.count : (object)o.glarch; } public void SetPropertyValue(object component, int property, object value) { Multiplicity o = (Multiplicity) component; if (property==0) *************** *** 21,26 **** public System.Type ReturnedClass { ! get ! { return typeof(Multiplicity); } } public new bool Equals(object x, object y) { Multiplicity mx = (Multiplicity) x; --- 16,20 ---- public System.Type ReturnedClass { ! get { return typeof(Multiplicity); } } public new bool Equals(object x, object y) { Multiplicity mx = (Multiplicity) x; *************** *** 30,36 **** return mx.count==my.count && mx.glarch==my.glarch; } public object NullSafeGet(IDataReader rs, String[] names, Engine.ISessionImplementor session, Object owner) { int c = (int) NHibernate.Int32.NullSafeGet( rs, names[0], session, owner); ! GlarchProxy g = (GlarchProxy) NHibernate.GetSerializable(typeof(Glarch)).NullSafeGet(rs, names[1], session, owner); Multiplicity m = new Multiplicity(); ! m.count = c==0 ? 0 : c; m.glarch = g; return m; --- 24,30 ---- return mx.count==my.count && mx.glarch==my.glarch; } public object NullSafeGet(IDataReader rs, String[] names, Engine.ISessionImplementor session, Object owner) { int c = (int) NHibernate.Int32.NullSafeGet( rs, names[0], session, owner); ! GlarchProxy g = (GlarchProxy) NHibernate.Entity(typeof(Glarch)).NullSafeGet(rs, names[1], session, owner); Multiplicity m = new Multiplicity(); ! m.count = ( c==0 ? 0 : c ); m.glarch = g; return m; *************** *** 38,56 **** public void NullSafeSet(IDbCommand st, Object value, int index, Engine.ISessionImplementor session) { ! Multiplicity o = (Multiplicity) value; ! GlarchProxy g; int c; if (o==null) ! { ! g=null; ! c=0; ! } else ! { ! g = o.glarch; ! c =o.count; } ! NHibernate.Int32.NullSafeSet(st, c, index, session); ! NHibernate.GetSerializable(typeof(Glarch)).NullSafeSet(st, g, index+1, session); } public object DeepCopy(object value) { if (value==null) return null; Multiplicity v = (Multiplicity) value; --- 32,50 ---- public void NullSafeSet(IDbCommand st, Object value, int index, Engine.ISessionImplementor session) { ! Multiplicity o = (Multiplicity) value; ! GlarchProxy g; int c; if (o==null) ! { ! g=null; ! c=0; ! } else ! { ! g = o.glarch; ! c = o.count; } ! NHibernate.Int32.NullSafeSet(st, c, index, session); ! NHibernate.Entity(typeof(Glarch)).NullSafeSet(st, g, index+1, session); } public object DeepCopy(object value) { if (value==null) return null; Multiplicity v = (Multiplicity) value; *************** *** 61,66 **** public bool IsMutable { ! get ! { return true; } } public object Assemble(object cached, Engine.ISessionImplementor session, Object owner) { throw new InvalidOperationException(); } --- 55,59 ---- public bool IsMutable { ! get { return true; } } public object Assemble(object cached, Engine.ISessionImplementor session, Object owner) { throw new InvalidOperationException(); } Index: Master.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Master.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Master.cs 2 Jun 2004 04:53:24 -0000 1.1 --- Master.cs 3 Jun 2004 14:29:00 -0000 1.2 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Collections; namespace NHibernate.DomainModel *************** *** 6,17 **** /// Summary description for Master. /// </summary> public class Master { ! public Master() { ! // ! // TODO: Add constructor logic here ! // } } } --- 7,103 ---- /// Summary description for Master. /// </summary> + [Serializable] public class Master { ! private static object _emptyObject = new object(); ! ! private Master _otherMaster; ! private IDictionary _details = new Hashtable(); ! private IDictionary _moreDetails = new Hashtable(); ! private IDictionary _incoming = new Hashtable(); ! private IDictionary _outgoing = new Hashtable(); ! private string _name = "master"; ! private DateTime _stamp; ! // private BigDecimal bigDecimal = new BigDecimal("1234.123"); TODO: how to do in .net ! private int _x; ! ! public Master OtherMaster { ! get { return _otherMaster; } ! set { _otherMaster = value; } ! } ! ! public void AddDetail(Detail d) ! { ! _details.Add(d, _emptyObject); ! } ! ! public void RemoveDetail(Detail d) ! { ! _details.Remove(d); ! } ! ! public IDictionary Details ! { ! get { return _details; } ! set { _details = value; } ! } ! ! public IDictionary MoreDetails ! { ! get { return _moreDetails; } ! set { _moreDetails = value; } ! } ! ! public void AddIncoming(Master m) ! { ! _incoming.Add(m, _emptyObject); ! } ! ! public void RemoveIncoming(Master m) ! { ! _incoming.Remove(m); ! } ! ! public IDictionary Incoming ! { ! get { return _incoming; } ! set { _incoming = value; } } + + public void AddOutgoing(Master m) + { + _outgoing.Add(m, _emptyObject); + } + + public void RemoveOutgoing(Master m) + { + _outgoing.Remove(m); + } + + public IDictionary Outgoing + { + get { return _outgoing; } + set { _outgoing = value; } + } + + public string Name + { + get { return _name; } + set { _name = value; } + } + + public DateTime Stamp + { + get { return _stamp; } + set { _stamp = value; } + } + + public int X + { + get { return _x; } + set { _x = value; } + } + } } --- NEW FILE: Middle.cs --- using System; namespace NHibernate.DomainModel { /// <summary> /// Summary description for Middle. /// </summary> [Serializable] public class Middle { private MiddleKey _id; private string _bla; public MiddleKey Id { get { return _id; } set { _id = value; } } public string Bla { get { return _bla; } set { _bla = value; } } #region System.Object Members public override bool Equals(object obj) { if(this==obj) return true; Middle cidMaster = obj as Middle; if(cidMaster==null) return false; if(_id!=null ? !_id.Equals(cidMaster.Id) : cidMaster.Id!=null) return false; return true; } public override int GetHashCode() { return ( _id!=null ? _id.GetHashCode() : 0 ); } #endregion } } |