Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10901/NHibernate/Cfg
Modified Files:
Binder.cs Mappings.cs
Log Message:
Added code so the auto-import works now.
Index: Mappings.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Mappings.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Mappings.cs 22 Apr 2003 22:05:52 -0000 1.4
--- Mappings.cs 12 Apr 2004 05:43:26 -0000 1.5
***************
*** 50,54 ****
public void AddImport(string className, string rename) {
! if ( (string)imports[rename] != className)
throw new MappingException("duplicate import: " + rename);
imports.Add(rename, className);
--- 50,54 ----
public void AddImport(string className, string rename) {
! if ( imports.Contains(rename) && (string)imports[rename] != className)
throw new MappingException("duplicate import: " + rename);
imports.Add(rename, className);
Index: Binder.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Binder.cs,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Binder.cs 9 Apr 2004 12:37:55 -0000 1.12
--- Binder.cs 12 Apr 2004 05:43:26 -0000 1.13
***************
*** 54,58 ****
//import
if (mapping.IsAutoImport) {
! mapping.AddImport( className, StringHelper.Unqualify(className) );
}
}
--- 54,58 ----
//import
if (mapping.IsAutoImport) {
! mapping.AddImport( StringHelper.GetFullClassname(className), StringHelper.GetClassname(className) );
}
}
***************
*** 86,90 ****
XmlAttribute tableNameNode = node.Attributes["table"];
string tableName = (tableNameNode==null)
! ? StringHelper.Unqualify( model.PersistentClazz.Name )
: tableNameNode.Value;
--- 86,90 ----
XmlAttribute tableNameNode = node.Attributes["table"];
string tableName = (tableNameNode==null)
! ? model.PersistentClazz.Name
: tableNameNode.Value;
***************
*** 117,121 ****
XmlAttribute tableNameNode = node.Attributes["table"];
string tableName = (tableNameNode==null)
! ? StringHelper.Unqualify( model.PersistentClazz.Name )
: tableNameNode.Value;
--- 117,121 ----
XmlAttribute tableNameNode = node.Attributes["table"];
string tableName = (tableNameNode==null)
! ? model.PersistentClazz.Name
: tableNameNode.Value;
***************
*** 855,858 ****
--- 855,861 ----
model.DefaultCascade = (dcNode==null) ? "none" : dcNode.Value ;
+ XmlAttribute aiNode = hmNode.Attributes["auto-import"];
+ model.IsAutoImport = (aiNode==null) ? true : "true".Equals( aiNode.Value );
+
nsmgr = new XmlNamespaceManager(doc.NameTable);
// note that the prefix has absolutely nothing to do with what the user
***************
*** 874,877 ****
--- 877,889 ----
model.AddQuery(qname, query);
}
+
+ foreach(XmlNode n in hmNode.SelectNodes(nsPrefix + ":import", nsmgr) )
+ {
+ string className = n.Attributes["class"].Value;
+ XmlAttribute renameNode = n.Attributes["rename"];
+ string rename = (renameNode==null) ? StringHelper.GetClassname(className) : renameNode.Value;
+ log.Debug("Import: " + rename + " -> " + className);
+ model.AddImport(className, rename);
+ }
}
|