Update of /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Mapping.Attributes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4811/src/NHibernate.Mapping.Attributes Added Files: .cvsignore AssemblyInfo.cs CascadeType.cs ClassAttribute.cs ClassPolymorphismType.cs CollectionCompositeElementAttribute.cs CollectionIndexAttribute.cs CollectionKeyAttribute.cs CollectionManyToManyAttribute.cs CollectionOneToManyAttribute.cs DiscriminatorAttribute.cs GeneratorParameterAttribute.cs IdAttribute.cs JoinedSubclassAttribute.cs JoinedSubclassKeyAttribute.cs ListAttribute.cs ManyToOneAttribute.cs MapGenerator.cs NHibernate.Mapping.Attributes-1.1.csproj NHibernate.Mapping.Attributes.build OuterJoinType.cs PropertyAttribute.cs SetAttribute.cs Size.cs SubclassAttribute.cs TypeKey.cs TypeNode.cs TypeNodeCollection.cs UnsavedValueType.cs VersionAttribute.cs readme.txt Log Message: Moved the Net2Hbm project into the NHibernate.Mapping.Attributes project. --- NEW FILE: ListAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for ListAttribute. /// </summary> [AttributeUsage(AttributeTargets.Property)] public class ListAttribute : Attribute { #region Member Variables private string m_Table; private string m_Schema; private bool m_IsLazy; private bool m_IsInverse; private CascadeType m_Cascade = CascadeType.None; private string m_SqlWhere; private string m_Access = MapGenerator.DefaultAccessStrategy; #endregion /// <summary> /// Class constructor. /// </summary> public ListAttribute( string table ) { this.Table = table; } /// <summary> /// Gets and sets the Table. /// </summary> public string Table { get { return m_Table; } set { m_Table = value; } } /// <summary> /// Gets and sets the IsInverse. /// </summary> public bool IsInverse { get { return m_IsInverse; } set { m_IsInverse = value; } } /// <summary> /// Gets and sets the Schema. /// </summary> public string Schema { get { return m_Schema; } set { m_Schema = value; } } /// <summary> /// Gets and sets the IsLazy. /// </summary> public bool IsLazy { get { return m_IsLazy; } set { m_IsLazy = value; } } /// <summary> /// Gets and sets the Cascade. /// </summary> public CascadeType Cascade { get { return m_Cascade; } set { m_Cascade = value; } } /// <summary> /// Gets and sets the SqlWhere. /// </summary> public string SqlWhere { get { return m_SqlWhere; } set { m_SqlWhere = value; } } /// <summary> /// Gets and sets the Access. /// </summary> public string Access { get { return m_Access; } set { m_Access = value; } } /// <summary> /// Get and sets the access type. /// </summary> public Type AccessType { get { return Type.GetType( m_Access ); } set { m_Access = String.Format( "{0}, {1}", value.FullName, value.Assembly.GetName().Name ); } } } } --- NEW FILE: TypeKey.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for TypeKey. /// </summary> internal class TypeKey : IComparable { #region Member Variables private System.Type m_Type; private System.Type m_ExtendsType; #endregion /// <summary> /// Class constructor. /// </summary> public TypeKey( System.Type type ) { m_Type = type; m_ExtendsType = FindExtendsType( type ); } /// <summary> /// Searchs the class hieracrhy for the first class with an attribute that we are looking for. /// </summary> /// <param name="type"></param> /// <returns></returns> private System.Type FindExtendsType( System.Type type ) { //check for joined subclass JoinedSubclassAttribute joinedSubclassAttr = (JoinedSubclassAttribute)Attribute.GetCustomAttribute( type, typeof(JoinedSubclassAttribute), false ); if( joinedSubclassAttr != null ) { if( joinedSubclassAttr.Extends != null ) { return joinedSubclassAttr.Extends; } else { return type.BaseType; } } else //check for subclass { SubclassAttribute subclassAttr = (SubclassAttribute)Attribute.GetCustomAttribute( type, typeof(SubclassAttribute), false ); if( subclassAttr != null ) { if( subclassAttr.Extends != null ) { return subclassAttr.Extends; } else { return type.BaseType; } } else //look to the base class { if( type.BaseType != null ) return FindExtendsType( type.BaseType ); else return null; } } } /// <summary> /// Gets and sets the Type. /// </summary> public System.Type Type { get { return m_Type; } } /// <summary> /// Gets and sets the ExtendsType. /// </summary> public System.Type ExtendsType { get { return m_ExtendsType; } } #region IComparable Members /// <summary> /// Compares the two objects. /// </summary> /// <param name="obj"></param> /// <returns></returns> public int CompareTo( object obj ) { if( obj is TypeKey ) { TypeKey other = (TypeKey)obj; if( this.Type == other.Type ) { return 0; } else if( this.ExtendsType == other.Type ) { return 1; } else if( other.ExtendsType == this.Type ) { return -1; } else { return -1; } } else { throw new ArgumentException(); } } #endregion } } --- NEW FILE: PropertyAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for PropertyAttribute. /// </summary> [AttributeUsage(AttributeTargets.Property)] public class PropertyAttribute : Attribute { #region Member Variables private string m_Column; private System.Type m_Type; private string m_Access = MapGenerator.DefaultAccessStrategy; private bool m_Update = true; private bool m_Insert = true; private string m_Formula; private int m_Size; #endregion /// <summary> /// Class constructor. /// </summary> public PropertyAttribute() { } /// <summary> /// Class constructor. /// </summary> /// <param name="type"></param> public PropertyAttribute( System.Type type ) { this.Type = type; } /// <summary> /// Class constructor. /// </summary> /// <param name="column"></param> /// <param name="type"></param> public PropertyAttribute( string column, System.Type type ) : this( column ) { this.Type = type; } /// <summary> /// Class constructor. /// </summary> /// <param name="column"></param> /// <param name="type"></param> /// <param name="size"></param> public PropertyAttribute( string column, System.Type type, int size ) : this( column, size ) { this.Type = type; } /// <summary> /// Class constructor. /// </summary> /// <param name="size"></param> public PropertyAttribute( int size ) { this.Size = size; } /// <summary> /// Class constructor. /// </summary> public PropertyAttribute( string column ) { this.Column = column; } /// <summary> /// Class constructor. /// </summary> /// <param name="column"></param> /// <param name="size"></param> public PropertyAttribute( string column, int size ) : this( column ) { this.Size = size; } /// <summary> /// Gets and sets the Size. /// </summary> public int Size { get { return m_Size; } set { m_Size = value; } } /// <summary> /// Gets and sets the Access. /// </summary> public string Access { get { return m_Access; } set { m_Access = value; } } /// <summary> /// Get and sets the access type. /// </summary> public Type AccessType { get { return Type.GetType( m_Access ); } set { m_Access = String.Format( "{0}, {1}", value.FullName, value.Assembly.GetName().Name ); } } /// <summary> /// Gets and sets the Column. /// </summary> public string Column { get { return m_Column; } set { m_Column = value; } } /// <summary> /// Gets and sets the Type. /// </summary> public System.Type Type { get { return m_Type; } set { m_Type = value; } } /// <summary> /// Gets and sets the Update. /// </summary> public bool Update { get { return m_Update; } set { m_Update = value; } } /// <summary> /// Gets and sets the Insert. /// </summary> public bool Insert { get { return m_Insert; } set { m_Insert = value; } } /// <summary> /// Gets and sets the Formula. /// </summary> public string Formula { get { return m_Formula; } set { m_Formula = value; } } } } --- NEW FILE: IdAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for IdAttribute. /// </summary> [AttributeUsage(AttributeTargets.Property)] public class IdAttribute : Attribute { #region Member Variables private string m_Column; private string m_Access = MapGenerator.DefaultAccessStrategy; private UnsavedValueType m_UnsavedValueType = UnsavedValueType.Null; private string m_UnsavedValue; private System.Type m_Generator; #endregion /// <summary> /// Class constructor. /// </summary> public IdAttribute( string column, System.Type generator ) { this.Column = column; this.Generator = generator; } /// <summary> /// Gets and sets the Column. /// </summary> public string Column { get { return m_Column; } set { m_Column = value; } } /// <summary> /// Gets and sets the Access. /// </summary> public string Access { get { return m_Access; } set { m_Access = value; } } /// <summary> /// Get and sets the access type. /// </summary> public Type AccessType { get { return Type.GetType( m_Access ); } set { m_Access = String.Format( "{0}, {1}", value.FullName, value.Assembly.GetName().Name ); } } /// <summary> /// Gets and sets the UnsavedValueType. /// </summary> public UnsavedValueType UnsavedValueType { get { return m_UnsavedValueType; } set { m_UnsavedValueType = value; } } /// <summary> /// Gets and sets the UnsavedValue. /// </summary> public string UnsavedValue { get { return m_UnsavedValue; } set { m_UnsavedValue = value; } } /// <summary> /// Gets and sets the Generator. /// </summary> public System.Type Generator { get { return m_Generator; } set { m_Generator = value; } } } } --- NEW FILE: SetAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for SetAttribute. /// </summary> [AttributeUsage(AttributeTargets.Property)] public class SetAttribute : Attribute { #region Member Variables private string m_Table; private string m_Schema; private bool m_IsLazy; private CascadeType m_Cascade = CascadeType.None; private string m_SqlWhere; private string m_Access = MapGenerator.DefaultAccessStrategy; #endregion /// <summary> /// Class constructor. /// </summary> public SetAttribute( string table ) { this.Table = table; } /// <summary> /// Gets and sets the Table. /// </summary> public string Table { get { return m_Table; } set { m_Table = value; } } /// <summary> /// Gets and sets the Schema. /// </summary> public string Schema { get { return m_Schema; } set { m_Schema = value; } } /// <summary> /// Gets and sets the IsLazy. /// </summary public bool IsLazy { get { return m_IsLazy; } set { m_IsLazy = value; } } /// <summary> /// Gets and sets the Cascade. /// </summary> public CascadeType Cascade { get { return m_Cascade; } set { m_Cascade = value; } } /// <summary> /// Gets and sets the SqlWhere. /// </summary> public string SqlWhere { get { return m_SqlWhere; } set { m_SqlWhere = value; } } /// <summary> /// Gets and sets the Access. /// </summary> public string Access { get { return m_Access; } set { m_Access = value; } } /// <summary> /// Get and sets the access type. /// </summary> public Type AccessType { get { return Type.GetType( m_Access ); } set { m_Access = String.Format( "{0}, {1}", value.FullName, value.Assembly.GetName().Name ); } } } } --- NEW FILE: CollectionManyToManyAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for CollectionManyToManyAttribute. /// </summary> [AttributeUsage(AttributeTargets.Property)] public class CollectionManyToManyAttribute : Attribute { #region Member Variables private string m_Column; private OuterJoinType m_OuterJoin; private System.Type m_Type; #endregion /// <summary> /// Class constructor. /// </summary> public CollectionManyToManyAttribute( string column, System.Type type ) { this.Column = column; this.Type = type; } /// <summary> /// Gets and sets the Column. /// </summary> public string Column { get { return m_Column; } set { m_Column = value; } } /// <summary> /// Gets and sets the OuterJoin. /// </summary> public OuterJoinType OuterJoin { get { return m_OuterJoin; } set { m_OuterJoin = value; } } /// <summary> /// Gets and sets the Type. /// </summary> public System.Type Type { get { return m_Type; } set { m_Type = value; } } } } --- NEW FILE: NHibernate.Mapping.Attributes.build --- <?xml version="1.0" ?> <project name="NHibernate.Mapping.Attributes" default="build" xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd" > <!-- Required properties: * build.dir - (path) root level to build to, assemblies will go in ${build.dir}/bin * build.debug - (true|false) debug build? * current.build.defines - framework-specific build defines * project.version - full project version * project.version.major - the major number of the build * project.version.minor - the minor number of the build * project.version.build - the build number * sign - (true|false)indicates if the Assembly should be signed. * clover.enabled - (true|false) indicates if Clover.NET should handle the build * clover.src - location of the clovered source to be stored at from the root of NHibernateContrib * clover.db - location of the coverage db from the root of NHibernateContrib * clover.assembly - assembly that contains clover tasks for this version of NAnt --> <if test="${clover.enabled}"> <loadtasks assembly="${clover.home}/${clover.assembly}" /> </if> <property name="keyFile" value="..\NHibernate.snk" /> <target name="build" description="Build NHibernate.Mapping.Attributes"> <if test="${clover.enabled}"> <clover-setup initstring="..\..\${clover.db}" builddir="..\..\${clover.src}\${nant.project.name}" enabled="${clover.enabled}" flushinterval="1000" /> </if> <!-- ensure the AssemblyInfo is writable --> <attrib file="AssemblyInfo.cs" readonly="false" /> <asminfo output="AssemblyInfo.cs" language="CSharp"> <imports> <import namespace="System" /> <import namespace="System.Reflection" /> <import namespace="System.Runtime.CompilerServices" /> </imports> <attributes> <attribute type="CLSCompliantAttribute" value="true" /> <attribute type="AssemblyTitleAttribute" value="${nant.project.name} for ${current.runtime.description}" /> <attribute type="AssemblyDescriptionAttribute" value="An attribute library which provides support for custom attributes that can be used in the generation of NHibernate ${project.version} mapping files." /> <attribute type="AssemblyCompanyAttribute" value="nhibernate.sourceforge.net" /> <attribute type="AssemblyProductAttribute" value="${nant.project.name}" /> <attribute type="AssemblyCopyrightAttribute" value="Licensed under LGPL." /> <attribute type="AssemblyVersionAttribute" value="0.5.0.0" /> <attribute type="AssemblyInformationalVersionAttribute" value="0.5" /> <attribute type="AssemblyFileVersionAttribute" value="0.5.0.0" /> <attribute type="AssemblyKeyFileAttribute" value="${keyFile}" if="${sign}"/> </attributes> </asminfo> <csc target="library" define="${current.build.defines}" debug="${build.debug}" output="${build.dir}/bin/${nant.project.name}.dll" doc="${build.dir}/bin/${nant.project.name}.xml" > <sources failonempty="true"> <include name="**/*.cs" /> </sources> <references basedir="${build.dir}/bin"> <include name="${nant.settings.currentframework.frameworkassemblydirectory}/System.dll" /> <include name="${nant.settings.currentframework.frameworkassemblydirectory}/System.Data.dll" /> <include name="${nant.settings.currentframework.frameworkassemblydirectory}/System.XML.dll" /> </references> </csc> </target> </project> --- NEW FILE: Size.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for Size. /// </summary> public class Size { #region Member Variables public const int Max = 2147483647; #endregion /// <summary> /// Class constructor. /// </summary> private Size() { } } } --- NEW FILE: AssemblyInfo.cs --- using System; using System.Reflection; using System.Runtime.CompilerServices; //------------------------------------------------------------------------------ // <autogenerated> // This code was generated by a tool. // Runtime Version: 1.1.4322.573 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </autogenerated> //------------------------------------------------------------------------------ [assembly: CLSCompliantAttribute(true)] [assembly: AssemblyTitleAttribute("NHibernate.Mapping.Attributes for Microsoft .NET Framework 1.1")] [assembly: AssemblyDescriptionAttribute("An attribute library which provides support for custom attributes that can be use" + "d in the generation of NHibernate 0.8.0.0 mapping files.")] [assembly: AssemblyCompanyAttribute("nhibernate.sourceforge.net")] [assembly: AssemblyProductAttribute("NHibernate.Mapping.Attributes")] [assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] [assembly: AssemblyVersionAttribute("0.8.0.0")] [assembly: AssemblyInformationalVersionAttribute("0.8")] [assembly: AssemblyFileVersionAttribute("0.8.0.0")] --- NEW FILE: CollectionKeyAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for CollectionKeyAttribute. /// </summary> [AttributeUsage(AttributeTargets.Property)] public class CollectionKeyAttribute : Attribute { #region Member Variables private string m_Column; #endregion /// <summary> /// Class constructor. /// </summary> public CollectionKeyAttribute( string column ) { this.Column = column; } /// <summary> /// Gets and sets the Column. /// </summary> public string Column { get { return m_Column; } set { m_Column = value; } } } } --- NEW FILE: UnsavedValueType.cs --- using System; using System.Xml.Serialization; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for UnsavedValueType. /// </summary> public enum UnsavedValueType { [XmlEnum("null")] Null, [XmlEnum("any")] Any, [XmlEnum("none")] None, Specified } } --- NEW FILE: ClassPolymorphismType.cs --- using System; using System.Xml.Serialization; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for ClassPolymorphismType. /// </summary> public enum ClassPolymorphismType { [XmlEnum("implicit")] Implicit = 0, [XmlEnum("explicit")] Explicit = 1 } } --- NEW FILE: NHibernate.Mapping.Attributes-1.1.csproj --- <VisualStudioProject> <CSHARP ProjectType = "Local" ProductVersion = "7.10.3077" SchemaVersion = "2.0" ProjectGuid = "{FD72BBE4-AA77-459A-9F1D-6B7C7143CF2A}" > <Build> <Settings ApplicationIcon = "" AssemblyKeyContainerName = "" AssemblyName = "NHibernate.Mapping.Attributes" AssemblyOriginatorKeyFile = "" DefaultClientScript = "JScript" DefaultHTMLPageLayout = "Grid" DefaultTargetSchema = "IE50" DelaySign = "false" OutputType = "Library" PreBuildEvent = "" PostBuildEvent = "" RootNamespace = "NHibernate.Mapping.Attributes" RunPostBuildEvent = "OnBuildSuccess" StartupObject = "" > <Config Name = "Debug" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "DEBUG;TRACE" DocumentationFile = "" DebugSymbols = "true" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "false" OutputPath = "bin\Debug\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> <Config Name = "Release" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "TRACE" DocumentationFile = "" DebugSymbols = "false" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "true" OutputPath = "bin\Release\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> </Settings> <References> <Reference Name = "System" AssemblyName = "System" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" /> <Reference Name = "System.Data" AssemblyName = "System.Data" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" /> <Reference Name = "System.XML" AssemblyName = "System.Xml" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> </References> </Build> <Files> <Include> <File RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "CascadeType.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ClassAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ClassPolymorphismType.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "CollectionCompositeElementAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "CollectionIndexAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "CollectionKeyAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "CollectionManyToManyAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "CollectionOneToManyAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "DiscriminatorAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "GeneratorParameterAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "IdAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "JoinedSubclassAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "JoinedSubclassKeyAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ListAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "ManyToOneAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "MapGenerator.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NHibernate.Mapping.Attributes.build" BuildAction = "None" /> <File RelPath = "OuterJoinType.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "PropertyAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "readme.txt" BuildAction = "Content" /> <File RelPath = "SetAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Size.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "SubclassAttribute.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TypeKey.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TypeNode.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "TypeNodeCollection.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "UnsavedValueType.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "VersionAttribute.cs" SubType = "Code" BuildAction = "Compile" /> </Include> </Files> </CSHARP> </VisualStudioProject> --- NEW FILE: CascadeType.cs --- using System; using System.Xml.Serialization; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for Cascade. /// </summary> public enum CascadeType { [XmlEnum("none")] None, [XmlEnum("all")] All, [XmlEnum("save-update")] SaveUpdate, [XmlEnum("delete")] Delete } } --- NEW FILE: CollectionIndexAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for CollectionIndexAttribute. /// </summary> [AttributeUsage(AttributeTargets.Property)] public class CollectionIndexAttribute : Attribute { #region Member Variables private string m_Column; #endregion /// <summary> /// Class constructor. /// </summary> public CollectionIndexAttribute( string column ) { this.Column = column; } /// <summary> /// Gets and sets the Column. /// </summary> public string Column { get { return m_Column; } set { m_Column = value; } } } } --- NEW FILE: readme.txt --- NHibernate.Mapping.Attributes ---------------------------------------------------- The NHibernate.Mapping.Attributes tool can be used to generate NHibernate mapping documents. The tool uses .NET attributes to allow the programmer to decorate their code with attributes. These attributes are interpreted by the MapGenerator class. The resulting map stream can be used to configure the NHibernate configuration object. --- NEW FILE: TypeNode.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for TypeNode. /// </summary> internal class TypeNode { #region Member Variables private System.Type m_Type; private TypeNodeCollection m_Nodes; #endregion /// <summary> /// Class constructor. /// </summary> public TypeNode( System.Type type ) { m_Type = type; m_Nodes = new TypeNodeCollection(); } /// <summary> /// Gets and sets the Nodes. /// </summary> public TypeNodeCollection Nodes { get { return m_Nodes; } } /// <summary> /// Gets and sets the Type. /// </summary> public System.Type Type { get { return m_Type; } set { m_Type = value; } } } } --- NEW FILE: .cvsignore --- bin obj .#* *.user *.xsx --- NEW FILE: JoinedSubclassAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for JoinedSubclassAttribute. /// </summary> [AttributeUsage(AttributeTargets.Class)] public class JoinedSubclassAttribute : Attribute { #region Member Variables private System.Type m_Extends; // private System.Type m_Proxy; private bool m_DynamicUpdate; private bool m_DynamicInsert; private string m_Table; #endregion /// <summary> /// Class constructor. /// </summary> public JoinedSubclassAttribute( string table ) { this.Table = table; } /// <summary> /// Class constructor. /// </summary> /// <param name="table"></param> /// <param name="extends"></param> public JoinedSubclassAttribute( string table, System.Type extends ) : this( table ) { this.Extends = extends; } /// <summary> /// Gets and sets the Table. /// </summary> public string Table { get { return m_Table; } set { m_Table = value; } } /// <summary> /// Gets and sets the Extends. /// </summary> public System.Type Extends { get { return m_Extends; } set { m_Extends = value; } } /// <summary> /// Gets and sets the DynamicUpdate. /// </summary> public bool DynamicUpdate { get { return m_DynamicUpdate; } set { m_DynamicUpdate = value; } } /// <summary> /// Gets and sets the DynamicInsert. /// </summary> public bool DynamicInsert { get { return m_DynamicInsert; } set { m_DynamicInsert = value; } } // /// <summary> // /// Gets and sets the Proxy. // /// </summary> // public System.Type Proxy // { // get { return m_Proxy; } // set { m_Proxy = value; } // } } } --- NEW FILE: OuterJoinType.cs --- using System; using System.Xml.Serialization; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for OuterJoinType. /// </summary> public enum OuterJoinType { [XmlEnum("auto")] Auto, [XmlEnum("true")] True, [XmlEnum("false")] False } } --- NEW FILE: ClassAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for ClassAttribute. /// </summary> [AttributeUsage(AttributeTargets.Class)] public class ClassAttribute : Attribute { #region Member Variables private string m_Table; private bool m_Mutable; private string m_Schema; private string m_DiscriminatorValue; // private System.Type m_Proxy; private bool m_DynamicUpdate; private bool m_DynamicInsert; private ClassPolymorphismType m_Polymorphism = ClassPolymorphismType.Implicit; private string m_SqlWhere; private System.Type m_Persister; #endregion /// <summary> /// Class constructor. /// </summary> public ClassAttribute( string table ) { this.Table = table; } /// <summary> /// Gets and sets the Table. /// </summary> public string Table { get { return m_Table; } set { m_Table = value; } } /// <summary> /// Gets and sets the DiscriminatorValue. /// </summary> public string DiscriminatorValue { get { return m_DiscriminatorValue; } set { m_DiscriminatorValue = value; } } /// <summary> /// Gets and sets the Mutable. /// </summary> public bool Mutable { get { return m_Mutable; } set { m_Mutable = value; } } /// <summary> /// Gets and sets the DynamicUpdate. /// </summary> public bool DynamicUpdate { get { return m_DynamicUpdate; } set { m_DynamicUpdate = value; } } /// <summary> /// Gets and sets the DynamicInsert. /// </summary> public bool DynamicInsert { get { return m_DynamicInsert; } set { m_DynamicInsert = value; } } /// <summary> /// Gets and sets the Polymorphism. /// </summary> public ClassPolymorphismType Polymorphism { get { return m_Polymorphism; } set { m_Polymorphism = value; } } /// <summary> /// Gets and sets the SqlWhere. /// </summary> public string SqlWhere { get { return m_SqlWhere; } set { m_SqlWhere = value; } } /// <summary> /// Gets and sets the Persister. /// </summary> public System.Type Persister { get { return m_Persister; } set { m_Persister = value; } } /// <summary> /// Gets and sets the Schema. /// </summary> public string Schema { get { return m_Schema; } set { m_Schema = value; } } // /// <summary> // /// Gets and sets the Proxy. // /// </summary> // public System.Type Proxy // { // get { return m_Proxy; } // set { m_Proxy = value; } // } } } --- NEW FILE: CollectionOneToManyAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for CollectionOneToManyAttribute. /// </summary> [AttributeUsage(AttributeTargets.Property)] public class CollectionOneToManyAttribute : Attribute { #region Member Variables private System.Type m_Type; #endregion /// <summary> /// Class constructor. /// </summary> public CollectionOneToManyAttribute( System.Type type ) { this.Type = type; } /// <summary> /// Gets and sets the Type. /// </summary> public System.Type Type { get { return m_Type; } set { m_Type = value; } } } } --- NEW FILE: JoinedSubclassKeyAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for JoinedSubclassKeyAttribute. /// </summary> [AttributeUsage(AttributeTargets.Class)] public class JoinedSubclassKeyAttribute : Attribute { #region Member Variables private string m_Column; #endregion /// <summary> /// Class constructor. /// </summary> public JoinedSubclassKeyAttribute( string column ) { this.Column = column; } /// <summary> /// Gets and sets the Column. /// </summary> public string Column { get { return m_Column; } set { m_Column = value; } } } } --- NEW FILE: GeneratorParameterAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for GeneratorParameterAttribute. /// </summary> [AttributeUsage(AttributeTargets.Property, AllowMultiple=true)] public class GeneratorParameterAttribute : Attribute { #region Member Variables private string m_Name; private string m_Value; #endregion /// <summary> /// Class constructor. /// </summary> public GeneratorParameterAttribute( string name, string value ) { m_Name = name; m_Value = value; } /// <summary> /// Gets and sets the Name. /// </summary> public string Name { get { return m_Name; } set { m_Name = value; } } /// <summary> /// Gets and sets the Value. /// </summary> public string Value { get { return m_Value; } set { m_Value = value; } } } } --- NEW FILE: CollectionCompositeElementAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for CollectionCompositeElementAttribute. /// </summary> [AttributeUsage(AttributeTargets.Property)] public class CollectionCompositeElementAttribute : Attribute { #region Member Variables private System.Type m_Type; #endregion /// <summary> /// Class constructor. /// </summary> public CollectionCompositeElementAttribute( System.Type type ) { this.Type = type; } /// <summary> /// Gets and sets the Type. /// </summary> public System.Type Type { get { return m_Type; } set { m_Type = value; } } } } --- NEW FILE: DiscriminatorAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for DiscriminatorAttribute. /// </summary> [AttributeUsage(AttributeTargets.Class)] public class DiscriminatorAttribute : Attribute { #region Member Variables private string m_Column; private System.Type m_Type; private bool m_Force; #endregion /// <summary> /// Class constructor. /// </summary> public DiscriminatorAttribute( string column, System.Type type ) { m_Column = column; m_Type = type; } /// <summary> /// Class constructor. /// </summary> /// <param name="column"></param> /// <param name="force"></param> public DiscriminatorAttribute( string column, System.Type type, bool force ) : this( column, type ) { m_Force = force; } /// <summary> /// Gets and sets the Column. /// </summary> public string Column { get { return m_Column; } set { m_Column = value; } } /// <summary> /// Gets and sets the Force. /// </summary> public bool Force { get { return m_Force; } set { m_Force = value; } } /// <summary> /// Gets and sets the Type. /// </summary> public System.Type Type { get { return m_Type; } set { m_Type = value; } } } } --- NEW FILE: ManyToOneAttribute.cs --- using System; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for ManyToOneAttribute. /// </summary> [AttributeUsage(AttributeTargets.Property)] public class ManyToOneAttribute : Attribute { #region Member Variables private string m_Column; private System.Type m_Type; private bool m_Update = true; private bool m_Insert = true; private OuterJoinType m_OuterJoin; private CascadeType m_Cascade; private bool m_Inheritable = true; private string m_Access = MapGenerator.DefaultAccessStrategy; #endregion /// <summary> /// Class constructor. /// </summary> /// <param name="type"></param> public ManyToOneAttribute( System.Type type ) { this.Type = type; } /// <summary> /// Class constructor. /// </summary> public ManyToOneAttribute( string column ) { this.Column = column; } /// <summary> /// Class constructor. /// </summary> public ManyToOneAttribute( string column, System.Type type ) : this( column ) { this.Type = type; } /// <summary> /// Gets and sets the Column. /// </summary> public string Column { get { return m_Column; } set { m_Column = value; } } /// <summary> /// Gets and sets the Update. /// </summary> public bool Update { get { return m_Update; } set { m_Update = value; } } /// <summary> /// Gets and sets the Insert. /// </summary> public bool Insert { get { return m_Insert; } set { m_Insert = value; } } /// <summary> /// Gets and sets the OuterJoin. /// </summary> public OuterJoinType OuterJoin { get { return m_OuterJoin; } set { m_OuterJoin = value; } } /// <summary> /// Gets and sets the Cascade. /// </summary> public CascadeType Cascade { get { return m_Cascade; } set { m_Cascade = value; } } /// <summary> /// Gets and sets the Inheritable. /// </summary> public bool Inheritable { get { return m_Inheritable; } set { m_Inheritable = value; } } /// <summary> /// Gets and sets the Type. /// </summary> public System.Type Type { get { return m_Type; } set { m_Type = value; } } /// <summary> /// Gets and sets the Access. /// </summary> public string Access { get { return m_Access; } set { m_Access = value; } } /// <summary> /// Get and sets the access type. /// </summary> public Type AccessType { get { return Type.GetType( m_Access ); } set { m_Access = String.Format( "{0}, {1}", value.FullName, value.Assembly.GetName().Name ); } } } } --- NEW FILE: MapGenerator.cs --- using System; using System.Collections; using System.Reflection; using System.IO; using System.Xml; using System.Xml.Serialization; using System.Text.RegularExpressions; namespace NHibernate.Mapping.Attributes { /// <summary> /// Summary description for MapGenerator. /// </summary> public sealed class MapGenerator { #region Constants public const string DefaultAccessStrategy = "property"; #endregion #region Member Variables private SortedList m_Types; #endregion /// <summary> /// Class constructor. /// </summary> public MapGenerator() { m_Types = new SortedList(); } /// <summary> /// Adds the assembly's types to the generator. /// </summary> /// <param name="assembly"></param> public void AddAssembly( string assembly ) { this.AddAssembly( Assembly.Load( assembly ) ); } /// <summary> /// Adds the assembly's types to the generator. /// </summary> /// <param name="assembly"></param> public void AddAssembly( Assembly assembly ) { System.Type[] types = assembly.GetTypes(); foreach( System.Type type in types ) { if( type.IsClass ) { AddClass( type ); } } } /// <summary> /// Adds the class type to the generator. /// </summary> /// <param name="type"></param> public void AddClass( System.Type type ) { if( type.IsClass ) { if( type.IsDefined( typeof(ClassAttribute), true ) || type.IsDefined( typeof(JoinedSubclassAttribute), true ) || type.IsDefined( typeof(SubclassAttribute), true ) ) { m_Types.Add( new TypeKey( type ), type ); } } else { throw new ArgumentException( "Invalid type. Only class types can be added to the generator.", "type" ); } } /// <summary> /// Generates the mapping. /// </summary> /// <param name="map"></param> public void Generate( Stream map ) { // //create the stream we will use to write the xml into // XmlWriter writer = new XmlTextWriter( map, System.Text.Encoding.UTF8 ); writer.WriteComment( String.Format( "Generated on {0}.", DateTime.Now ) ); writer.WriteStartElement("hibernate-mapping", "urn:nhibernate-mapping-2.0" ); // //write each type into the stream // TypeNodeCollection nodes = BuildTypeDependencyTree( m_Types ); foreach( TypeNode node in nodes ) { WriteTypeNode( writer, node ); } writer.WriteEndElement(); //</hibernate-mapping> writer.Flush(); } /// <summary> /// Writes the type's map information into the xml writer. /// </summary> /// <param name="writer"></param> /// <param name="node"></param> private void WriteTypeNode( XmlWriter writer, TypeNode node ) { bool looking = true; System.Type type = node.Type; while( looking ) { if( Attribute.IsDefined( type, typeof(ClassAttribute), false ) ) { writer.WriteComment( GetShortTypeName( node.Type ) ); WriteClass( writer, node, type ); looking = false; } else if( Attribute.IsDefined( type, typeof(JoinedSubclassAttribute), false ) ) { writer.WriteComment( GetShortTypeName( node.Type ) ); WriteJoinedSubclass( writer, node, type ); looking = false; } else if( Attribute.IsDefined( type, typeof(SubclassAttribute), false ) ) { writer.WriteComment( GetShortTypeName( node.Type ) ); WriteSubclass( writer, node, type ); looking = false; } else { type = type.BaseType; looking = true; } } } /// <summary> /// Writes the collection. /// </summary> /// <param name="writer"></param> /// <param name="type"></param> private void WriteCollections( XmlWriter writer, System.Type type ) { PropertyInfo[] listProps = FindAttributedProperties( typeof(ListAttribute), type ); foreach( PropertyInfo listProp in listProps ) { WriteList( writer, listProp ); } PropertyInfo[] setProps = FindAttributedProperties( typeof(SetAttribute), type ); foreach( PropertyInfo setProp in setProps ) { WriteSet( writer, setProp ); } } /// <summary> /// Writes the list. /// </summary> /// <param name="writer"></param> /// <param name="parentNode"></param> private void WriteList( XmlWriter writer, PropertyInfo property ) { ListAttribute attribute = (ListAttribute)Attribute.GetCustomAttribute( property, typeof(ListAttribute) ); writer.WriteStartElement( "list" ); writer.WriteAttributeString( "name", property.Name ); writer.WriteAttributeString( "table", attribute.Table ); writer.WriteAttributeString( "access", attribute.Access ); if( attribute.IsLazy ) writer.WriteAttributeString( "lazy", "true" ); if( attribute.IsInverse ) writer.WriteAttributeString( "inverse", "true" ); WriteCollectionKey( writer, property ); WriteCollectionIndex( writer, property ); WriteCollectionOneToMany( writer, property ); WriteCollectionCompositeElement( writer, property ); WriteCollectionManyToMany( writer, property ); writer.WriteEndElement(); //<list> } /// <summary> /// Writes the list. /// </summary> /// <param name="writer"></param> /// <param name="parentNode"></param> private void WriteSet( XmlWriter writer, PropertyInfo property ) { SetAttribute attribute = (SetAttribute)Attribute.GetCustomAttribute( property, typeof(SetAttribute) ); writer.WriteStartElement( "set" ); writer.WriteAttributeString( "name", property.Name ); writer.WriteAttributeString( "table", attribute.Table ); writer.WriteAttributeString( "access", attribute.Access ); if( attribute.IsLazy ) writer.WriteAttributeString( "lazy", "true" ); WriteCollectionKey( writer, property ); WriteCollectionOneToMany( writer, property ); WriteCollectionCompositeElement( writer, property ); writer.WriteEndElement(); //<list> } /// <summary> /// Writes the collection key. /// </summary> /// <param name="writer"></param> /// <param name="property"></param> private void WriteCollectionKey( XmlWriter writer, PropertyInfo property ) { CollectionKeyAttribute attribute = (CollectionKeyAttribute)Attribute.GetCustomAttribute( property, typeof(CollectionKeyAttribute) ); if( attribute != null ) { writer.WriteStartElement( "key" ); writer.WriteAttributeString( "column", attribute.Column ); writer.WriteEndElement(); //</key> } } /// <summary> /// Writes the collection index. /// </summary> /// <param name="writer"></param> /// <param name="type"></param> private void WriteDiscriminator( XmlWriter writer, System.Type type ) { DiscriminatorAttribute attribute = (DiscriminatorAttribute)Attribute.GetCustomAttribute( type, typeof(DiscriminatorAttribute) ); if( attribute != null ) { writer.WriteStartElement( "discriminator" ); writer.WriteAttributeString( "column", attribute.Column ); writer.WriteAttributeString( "type", GetShortTypeName( attribute.Type ) ); if( attribute.Force ) writer.WriteAttributeString( "force", "true" ); writer.WriteEndElement(); //</discriminator> } } /// <summary> /// Writes the collection index. /// </summary> /// <param name="writer"></param> /// <param name="property"></param> private void WriteCollectionIndex( XmlWriter writer, PropertyInfo property ) { CollectionIndexAttribute attribute = (CollectionIndexAttribute)Attribute.GetCustomAttribute( property, typeof(CollectionIndexAttribute) ); if( attribute != null ) { writer.WriteStartElement( "index" ); writer.WriteAttributeString( "column", attribute.Column ); writer.WriteEndElement(); //</index> } } /// <summary> /// Writes the collection composite element. /// </summary> /// <param name="writer"></param> /// <param name="property"></param> private void WriteCollectionCompositeElement( XmlWriter writer, PropertyInfo property ) { CollectionCompositeElementAttribute attribute = (CollectionCompositeElementAttribute)Attribute.GetCustomAttribute( property, typeof(CollectionCompositeElementAttribute) ); if( attribute != null ) { writer.WriteStartElement( "composite-element" ); writer.WriteAttributeString( "class", GetShortTypeName( attribute.Type ) ); WriteProperties( writer, attribute.Type ); writer.WriteEndElement(); //</composite-element> } } /// <summary> /// Writes the collection many to many. /// </summary> /// <param name="writer"></param> /// <param name="property"></param> private void WriteCollectionManyToMany( XmlWriter writer, PropertyInfo property ) { CollectionManyToManyAttribute attribute = (CollectionManyToManyAttribute)Attribute.GetCustomAttribute( property, typeof(CollectionManyToManyAttribute) ); if( attribute != null ) { writer.WriteStartElement( "many-to-many" ); writer.WriteAttributeString( "column", attribute.Column ); writer.WriteAttributeString( "class", GetShortTypeName( attribute.Type ) ); writer.WriteEndElement(); //</many-to-many> } } /// <summary> /// Writes the collection one to many tag. /// </summary> /// <param name="writer"></param> /// <param name="property"></param> private void WriteCollectionOneToMany( XmlWriter writer, PropertyInfo property ) { CollectionOneToManyAttribute attribute = (CollectionOneToManyAttribute)Attribute.GetCustomAttribute( property, typeof(CollectionOneToManyAttribute) ); if( attribute != null ) { writer.WriteStartElement( "one-to-many" ); writer.WriteAttributeString( "class", GetShortTypeName( attribute.Type ) ); writer.WriteEndElement(); //<one-to-many> } } /// <summary> /// Writes the subclass. /// </summary> private void WriteSubclass( XmlWriter writer, TypeNode node, System.Type type ) { SubclassAttribute attribute = (SubclassAttribute)Attribute.GetCustomAttribute( type, typeof(SubclassAttribute), true ); writer.WriteStartElement( "subclass" ); writer.WriteAttributeString( "name", GetShortTypeName( node.Type ) ); if( attribute.DiscriminatorValue != null ) writer.WriteAttributeString( "discriminator-value", attribute.DiscriminatorValue ); if( attribute.DynamicInsert ) writer.WriteAttributeString( "dynamic-insert", "true" ); if( attribute.DynamicUpdate ) writer.WriteAttributeString( "dynamic-update", "true" ); WriteProperties( writer, type ); WriteCollections( writer, type ); WriteAssociations( writer, type ); foreach( TypeNode childNode in node.Nodes ) { WriteTypeNode( writer, childNode ); } writer.WriteEndElement(); //</subclass> } /// <summary> /// Writes the class. /// </summary> private void WriteClass( XmlWriter writer, TypeNode node, System.Type type ) { ClassAttribute attribute = (ClassAttribute)Attribute.GetCustomAttribute( type, typeof(ClassAttribute), true ); writer.WriteStartElement( "class" ); writer.WriteAttributeString( "name", GetShortTypeName( node.Type ) ); writer.WriteAttributeString( "table", attribute.Table ); if( attribute.Polymorphism != ClassPolymorphismType.Implicit ) writer.WriteAttributeString( "polymorphism", GetXmlEnumValue( typeof(ClassPolymorphismType), attribute.Polymorphism ) ); if( attribute.DiscriminatorValue != null ) writer.WriteAttributeString( "discriminator-value", attribute.DiscriminatorValue ); if( attribute.SqlWhere != null ) writer.WriteAttributeString( "where", attribute.SqlWhere ); WriteId( writer, node.Type ); WriteDiscriminator( writer, type ); WriteVersion( writer, type ); WriteProperties( writer, type ); WriteCollections( writer, type ); WriteAssociations( writer, type ); foreach( TypeNode childNode in node.Nodes ) { WriteTypeNode( writer, childNode ); } writer.WriteEndElement(); //</class> } /// <summary> /// Writes the property. /// </summary> /// <param name="writer"></param> /// <param name="property"></param> private void WriteProperty( XmlWriter writer, PropertyInfo property ) { PropertyAttribute attribute = (PropertyAttribute)Attribute.GetCustomAttribute( property, typeof(PropertyAttribute) ); writer.WriteStartElement( "property" ); writer.WriteAttributeString( "name", property.Name ); writer.WriteAttributeString( "column", attribute.Column == null ? property.Name : attribute.Column ); writer.WriteAttributeString( "access", attribute.Access ); string typeName = null; if( attribute.Type != null ) typeName = GetShortTypeName( attribute.Type ); else typeName = GetShortTypeName( property.PropertyType ); if( attribute.Size > 0 ) { writer.WriteAttributeString( "type", String.Format( "{0}({1})", typeName, attribute.Size ) ); } else { writer.WriteAttributeString( "type", typeName ); } if( !attribute.Insert ) writer.WriteAttributeString( "insert", "false" ); if( !attribute.Update ) writer.WriteAttributeString( "update", "false" ); //if( attribute.Size > 0 ) // writer.WriteAttributeString( "length", attribute.Size.ToString() ); writer.WriteEndElement(); //</property> } /// <summary> /// Writers the properties. /// </summary> /// <param name="writer"></param> /// <param name="parentNode"></param> private void WriteProperties( XmlWriter writer, System.Type type ) { PropertyInfo[] properties = FindAttributedProperties( typeof(PropertyAttribute), type ); foreach( PropertyInfo property in properties ) { WriteProperty( writer, property ); } } /// <summary> /// Writes the assoications. /// </summary> /// <param name="writer"></param> /// <param name="type"></param> private void WriteAssociations( XmlWriter writer, System.Type type ) { PropertyInfo[] properties = FindAttributedProperties( typeof(ManyToOneAttribute), type ); foreach( PropertyInfo property in properties ) { WriteManyToOne( writer, property ); } } /// <summary> /// Writes the many to one association. /// </summary> /// <param name="writer"></param> /// <param name="property"></param> private void WriteManyToOne( XmlWriter writer, PropertyInfo property ) { ManyToOneAttribute attribute = (ManyToOneAttribute)Attribute.GetCustomAttribute( property, typeof(ManyToOneAttribute) ); if( attribute.Inheritable || ( !attribute.Inheritable && ( property.DeclaringType == property.ReflectedType ) ) ) { writer.WriteStartElement( "many-to-one" ); writer.WriteAttributeString( "name", property.Name ); writer.WriteAttributeString( "column", attribute.Column == null ? property.Name : attribute.Column ); writer.WriteAttributeString( "access", attribute.Access ); string typeName = null; if( attribute.Type != null ) typeName = GetShortTypeName( attribute.Type ); else typeName = GetShortTypeName( property.PropertyType ); writer.WriteAttributeString( "class", typeName ); if( attribute.Cascade != CascadeType.None ) writer.WriteAttributeString( "cascade", GetXmlEnumValue( typeof(CascadeType), attribute.Cascade ) ); if( attribute.OuterJoin != OuterJoinType.Auto ) writer.WriteAttributeString( "outer-join", GetXmlEnumValue( typeof(OuterJoinType), attribute.OuterJoin ) ); if( !attribute.Insert ) writer.WriteAttributeString( "insert", "false" ); if( !attribute.Update ) writer.WriteAttributeString( "update", "false" ); writer.WriteEndElement(); //</many-to-one> } } /// <summary> /// Writes the version. /// </summary> /// <param name="writer"></param> /// <param name="parentNode"></param> private void WriteVersion( XmlWriter writer, System.Type type ) { PropertyInfo property = FindAttributedProperty( typeof(VersionAttribute), type ); if( property != null ) { VersionAttribute attribute = (VersionAttribute)Attribute.GetCustomAttribute( property, typeof(VersionAttribute), false ); writer.WriteStartElement( "version" ); writer.WriteAttributeString( "name", property.Name ); writer.WriteAttributeString( "column", attribute.Column ); writer.WriteAttributeString( "type", GetShortTypeName( property.PropertyType ) ); writer.WriteAttributeString( "access", attribute.Access ); writer.WriteEndElement(); //</version> } } /// <summary> /// Writes the id. /// </summary> /// <param name="writer"></param> /// <param name="parentNode"></param> private void WriteId( XmlWriter writer, System.Type type ) { PropertyInfo property = FindAttributedProperty( typeof(IdAttribute), type ); if( property == null ) throw new Exception( "Missing required IdAttribute." ); IdAttribute attribute = (IdAttribute)Attribute.GetCustomAttribute( property, typeof(IdAttribute), false ); writer.WriteStartElement( "id" ); writer.WriteAttributeString( "name", property.Name ); writer.WriteAttributeString( "type", GetShortTypeName( property.PropertyType ) ); writer.WriteAttributeString( "column", attribute.Column ); writer.WriteAttributeString( "access", attribute.Access ); if( attribute.UnsavedValueType == UnsavedValueType.Specified ) writer.WriteAttributeString( "unsaved-value", attribute.UnsavedValue ); else writer.WriteAttributeString( "unsaved-value", GetXmlEnumValue( typeof(UnsavedValueType), attribute.UnsavedValueType ) ); writer.WriteStartElement("generator"); writer.WriteAttributeString( "class", GetShortTypeName( attribute.Generator ) ); WriteGeneratorParameters( writer, property ); writer.WriteEndElement(); //</generator> writer.WriteEndElement(); //</id> } /// <summary> /// Writes the generator parameters. /// </summary> /// <param name="writer"></param> /// <param name="property"></param> private void WriteGeneratorParameters( XmlWriter writer, PropertyInfo property ) { GeneratorParameterAttribute[] attributes = (GeneratorParameterAttribute[])Attribute.GetCustomAttributes( property, typeof(GeneratorParameterAttribute), true ); foreach( GeneratorParameterAttribute attribute in attributes ) { writer.WriteStartElement( "param" ); writer.WriteAttributeString( "name", attribute.Name ); writer.WriteString( attribute.Value ); writer.WriteEndElement(); //</param> } } /// <summary> /// Writes the joined subclass. /// </summary> private void WriteJ... [truncated message content] |