|
From: Chris M. <cm...@us...> - 2007-09-25 23:34:16
|
User: cmicali
Date: 07/09/25 15:47:32
Modified: andromda-cs/src/main/resources/templates/cs ValueObject.vsl
Log:
- Added XmlInclude for VO inheritance and Clone() method
- Fixed issue with dao->dao references
Revision Changes Path
1.4 +29 -1 cartridges/andromda-cs/src/main/resources/templates/cs/ValueObject.vsl
Index: ValueObject.vsl
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-cs/src/main/resources/templates/cs/ValueObject.vsl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- ValueObject.vsl 15 Aug 2006 22:48:43 -0000 1.3
+++ ValueObject.vsl 25 Sep 2007 22:47:32 -0000 1.4
@@ -4,7 +4,14 @@
// Attention: Generated code! Do not modify by hand!
// Generated by: ValueObject.vsl in andromda-cs-cartridge.
+#region Using statements
+
using System;
+using System.IO;
+using System.Xml.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+
+#endregion
#if ($stringUtils.isNotBlank($class.packageName))
namespace $class.packageName
@@ -14,9 +21,14 @@
$class.getDocumentation(" /// ")
/// </summary>
[Serializable]
+#foreach ($subentity in $class.specializations)
+ [XmlInclude(typeof(${subentity.name}))]
+#end
public#if($class.abstract) abstract#end class $class.name
#if($class.generalization)
- : ${class.generalization.fullyQualifiedName}
+ : ${class.generalization.fullyQualifiedName} , ICloneable
+#else
+ : ICloneable
#end
{
@@ -114,6 +126,22 @@
#end
#endregion
+ #region ICloneable Implementation
+
+ public#if($class.generalization) new#end object Clone()
+ {
+ ${class.name} _clone = default(${class.name}); //initialize to default not null
+ BinaryFormatter bf = new BinaryFormatter(); //helper to serialize
+ MemoryStream memStream = new MemoryStream();
+ bf.Serialize(memStream, this);
+ memStream.Flush();
+ memStream.Position = 0;
+ _clone = ((${class.name})bf.Deserialize(memStream)); //this returns the copy of type T
+ return _clone;
+ }
+
+ #endregion
+
// ValueObject.vsl merge-point
}
|