From: Michael D. <mik...@us...> - 2004-08-22 06:23:58
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31592/NHibernate/Persister Modified Files: AbstractEntityPersister.cs EntityPersister.cs NormalizedEntityPersister.cs Log Message: Added code to use IGetter and ISetter Index: NormalizedEntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/NormalizedEntityPersister.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** NormalizedEntityPersister.cs 19 Aug 2004 17:51:03 -0000 1.26 --- NormalizedEntityPersister.cs 22 Aug 2004 06:23:40 -0000 1.27 *************** *** 284,288 **** int propertyIndex = 0; ! foreach(Property prop in model.PropertyClosureCollection) { thisClassProperties.Add(prop, thisClassPropertiesObject); --- 284,288 ---- int propertyIndex = 0; ! foreach(Mapping.Property prop in model.PropertyClosureCollection) { thisClassProperties.Add(prop, thisClassPropertiesObject); *************** *** 315,319 **** Hashtable distinctColumns = new Hashtable(); CheckColumnDuplication(distinctColumns, model.Key.ColumnCollection); ! foreach(Property prop in model.PropertyCollection) { if(prop.IsUpdateable || prop.IsInsertable) --- 315,319 ---- Hashtable distinctColumns = new Hashtable(); CheckColumnDuplication(distinctColumns, model.Key.ColumnCollection); ! foreach(Mapping.Property prop in model.PropertyCollection) { if(prop.IsUpdateable || prop.IsInsertable) *************** *** 335,339 **** ArrayList definedBySubclass = new ArrayList(); // this.propertyDefinedOnSubclass ! foreach(Property prop in model.SubclassPropertyClosureCollection) { names.Add(prop.Name); --- 335,339 ---- ArrayList definedBySubclass = new ArrayList(); // this.propertyDefinedOnSubclass ! foreach(Mapping.Property prop in model.SubclassPropertyClosureCollection) { names.Add(prop.Name); Index: AbstractEntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/AbstractEntityPersister.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** AbstractEntityPersister.cs 16 Aug 2004 05:22:56 -0000 1.20 --- AbstractEntityPersister.cs 22 Aug 2004 06:23:40 -0000 1.21 *************** *** 70,75 **** [NonSerialized] private string identifierPropertyName; [NonSerialized] private IType identifierType; ! [NonSerialized] private ReflectHelper.Setter identifierSetter; ! [NonSerialized] private ReflectHelper.Getter identifierGetter; [NonSerialized] private PropertyInfo proxyIdentifierProperty; --- 70,75 ---- [NonSerialized] private string identifierPropertyName; [NonSerialized] private IType identifierType; ! [NonSerialized] private Property.ISetter identifierSetter; ! [NonSerialized] private Property.IGetter identifierGetter; [NonSerialized] private PropertyInfo proxyIdentifierProperty; *************** *** 82,90 **** [NonSerialized] private string versionColumnName; [NonSerialized] private IVersionType versionType; ! [NonSerialized] private ReflectHelper.Getter versionGetter; [NonSerialized] private int versionProperty; ! [NonSerialized] private ReflectHelper.Getter[] getters; ! [NonSerialized] private ReflectHelper.Setter[] setters; [NonSerialized] private readonly Hashtable gettersByPropertyName = new Hashtable(); [NonSerialized] private readonly Hashtable settersByPropertyName = new Hashtable(); --- 82,90 ---- [NonSerialized] private string versionColumnName; [NonSerialized] private IVersionType versionType; ! [NonSerialized] private Property.IGetter versionGetter; [NonSerialized] private int versionProperty; ! [NonSerialized] private Property.IGetter[] getters; ! [NonSerialized] private Property.ISetter[] setters; [NonSerialized] private readonly Hashtable gettersByPropertyName = new Hashtable(); [NonSerialized] private readonly Hashtable settersByPropertyName = new Hashtable(); *************** *** 248,257 **** } ! protected virtual ReflectHelper.Setter[] Setters { get { return setters; } } ! protected virtual ReflectHelper.Getter[] Getters { get { return getters; } --- 248,257 ---- } ! protected virtual Property.ISetter[] Setters { get { return setters; } } ! protected virtual Property.IGetter[] Getters { get { return getters; } *************** *** 451,471 **** hasEmbeddedIdentifier = model.HasEmbeddedIdentifier; - identifierPropertyName = model.HasIdentifierProperty ? model.IdentifierProperty.Name : null; Value idValue = model.Identifier; identifierType = idValue.Type; ! if (identifierPropertyName!=null) { ! identifierSetter = ReflectHelper.GetSetter(mappedClass, identifierPropertyName); ! identifierGetter = ReflectHelper.GetGetter(mappedClass, identifierPropertyName); ! ! PropertyInfo proxyGetter = identifierGetter.Property; ! try ! { ! System.Type proxy = model.ProxyInterface; ! if(proxy != null) proxyGetter = ReflectHelper.GetGetter( proxy, identifierPropertyName ).Property; ! } ! catch (Exception) {} ! proxyIdentifierProperty = proxyGetter; } else --- 451,463 ---- hasEmbeddedIdentifier = model.HasEmbeddedIdentifier; Value idValue = model.Identifier; identifierType = idValue.Type; ! if (model.HasIdentifierProperty) { ! Mapping.Property idProperty = model.IdentifierProperty; ! identifierPropertyName = idProperty.Name; ! identifierSetter = idProperty.GetSetter(mappedClass); ! identifierGetter = idProperty.GetGetter(mappedClass); } else *************** *** 476,479 **** --- 468,500 ---- } + //this code has been modified to be more like h2.1 because of IGetter + // and ISetter + System.Type prox = model.ProxyInterface; + PropertyInfo proxySetIdentifierMethod = null; + PropertyInfo proxyGetIdentifierMethod = null; + + if( model.HasIdentifierProperty && prox!=null) + { + Mapping.Property idProperty = model.IdentifierProperty; + + try + { + proxyGetIdentifierMethod = idProperty.GetGetter(prox).Property; + } + catch (PropertyNotFoundException) + { + } + + try + { + proxySetIdentifierMethod = idProperty.GetSetter(prox).Property; + } + catch (PropertyNotFoundException) + { + } + } + + proxyIdentifierProperty = proxyGetIdentifierMethod; + // HYDRATE SPAN *************** *** 546,550 **** versionPropertyName = model.Version.Name; versioned = true; ! versionGetter = ReflectHelper.GetGetter(mappedClass, versionPropertyName); // TODO: determine if this block is kept // this if-else block is extra logic in nhibernate - not sure if I like it - would rather throw --- 567,571 ---- versionPropertyName = model.Version.Name; versioned = true; ! versionGetter = model.Version.GetGetter(mappedClass); // TODO: determine if this block is kept // this if-else block is extra logic in nhibernate - not sure if I like it - would rather throw *************** *** 577,582 **** propertyUpdateability = new bool[hydrateSpan]; propertyInsertability = new bool[hydrateSpan]; ! getters = new ReflectHelper.Getter[hydrateSpan]; ! setters = new ReflectHelper.Setter[hydrateSpan]; cascadeStyles = new Cascades.CascadeStyle[hydrateSpan]; string[] setterNames = new string[hydrateSpan]; --- 598,603 ---- propertyUpdateability = new bool[hydrateSpan]; propertyInsertability = new bool[hydrateSpan]; ! getters = new Property.IGetter[hydrateSpan]; ! setters = new Property.ISetter[hydrateSpan]; cascadeStyles = new Cascades.CascadeStyle[hydrateSpan]; string[] setterNames = new string[hydrateSpan]; *************** *** 588,597 **** bool foundCascade = false; ! foreach(Property prop in model.PropertyClosureCollection) { if (prop==model.Version) tempVersionProperty = i; propertyNames[i] = prop.Name; ! getters[i] = ReflectHelper.GetGetter( mappedClass, propertyNames[i] ); ! setters[i] = ReflectHelper.GetSetter( mappedClass, propertyNames[i] ); getterNames[i] = getters[i].Property.Name; setterNames[i] = setters[i].Property.Name; --- 609,618 ---- bool foundCascade = false; ! foreach(Mapping.Property prop in model.PropertyClosureCollection) { if (prop==model.Version) tempVersionProperty = i; propertyNames[i] = prop.Name; ! getters[i] = prop.GetGetter( mappedClass ); ! setters[i] = prop.GetSetter( mappedClass ); getterNames[i] = getters[i].Property.Name; setterNames[i] = setters[i].Property.Name; *************** *** 713,717 **** public virtual object GetPropertyValue(object obj, string propertyName) { ! ReflectHelper.Getter getter = (ReflectHelper.Getter) gettersByPropertyName[propertyName]; if(getter==null) throw new HibernateException("unmapped property: " + propertyName); return getter.Get(obj); --- 734,738 ---- public virtual object GetPropertyValue(object obj, string propertyName) { ! Property.IGetter getter = (Property.IGetter) gettersByPropertyName[propertyName]; if(getter==null) throw new HibernateException("unmapped property: " + propertyName); return getter.Get(obj); *************** *** 720,724 **** public virtual void SetPropertyValue(object obj, string propertyName, object value) { ! ReflectHelper.Setter setter = (ReflectHelper.Setter) settersByPropertyName[propertyName]; if(setter==null) throw new HibernateException("unmapped property: " + propertyName); setter.Set(obj, value); --- 741,745 ---- public virtual void SetPropertyValue(object obj, string propertyName, object value) { ! Property.ISetter setter = (Property.ISetter ) settersByPropertyName[propertyName]; if(setter==null) throw new HibernateException("unmapped property: " + propertyName); setter.Set(obj, value); Index: EntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/EntityPersister.cs,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** EntityPersister.cs 16 Aug 2004 05:30:59 -0000 1.23 --- EntityPersister.cs 22 Aug 2004 06:23:40 -0000 1.24 *************** *** 144,148 **** int i=0; bool foundColumn = false; ! foreach(Property prop in model.PropertyClosureCollection) { thisClassProperties.Add(prop); --- 144,148 ---- int i=0; bool foundColumn = false; ! foreach(Mapping.Property prop in model.PropertyClosureCollection) { thisClassProperties.Add(prop); *************** *** 193,197 **** ArrayList definedBySubclass = new ArrayList(); ! foreach(Property prop in model.SubclassPropertyClosureCollection) { names.Add( prop.Name ); --- 193,197 ---- ArrayList definedBySubclass = new ArrayList(); ! foreach(Mapping.Property prop in model.SubclassPropertyClosureCollection) { names.Add( prop.Name ); |