<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'><BLOCKQUOTE>
<DIV> </DIV>
<DIV>---</DIV>
<DIV><FONT face=Arial>Stefan, It would be motivating if you could provide a sample about how the TribalMedia data framework should work. Could that be done by implementing the very simple asset server as an example ? I propose we would make it work, make tests, comment and try to improve it, then it may serve as a baseline for the other db stuff ?</FONT></DIV>
<DIV><FONT face=Arial></FONT>--- </DIV>
<DIV> </DIV>
<DIV>*doh*</DIV>
<DIV> </DIV>
<DIV>I'll just post the code; but beware, it doesn't work, it's just to show you how stuff would interact</DIV>
<DIV> </DIV>
<DIV>(Also, the code could probably be cleaner...)</DIV>
<DIV> </DIV>
<DIV>What to look for:</DIV>
<DIV>* how the Schema is created and populated</DIV>
<DIV>* how the m_keyFieldMapper (that is used to extract primary key from queries) is initialized</DIV>
<DIV>* how the FromReader passes on to FillObject() - the function that will use the Schema to populate the RowMapper (and the PrimitiveBaseShape)</DIV>
<DIV>* How the CRUD and CreateRowMapper functions are really just there to get a cleaner interface for the caller.</DIV>
<DIV> </DIV>
<DIV>/Stefan</DIV>
<DIV> </DIV>
<DIV>---</DIV>
<DIV> </DIV>
<DIV>using System;</DIV>
<DIV>namespace TribalMedia.Framework.Data<BR>{<BR>    public class PrimitiveBaseShapeRowMapper : RowMapper<PrimitiveBaseShape><BR>    {<BR>        public Guid SceneObjectPartId;</DIV>
<DIV>        public PrimitiveBaseShapeRowMapper(Schema schema, PrimitiveBaseShape obj) : base(schema, obj)<BR>        {<BR>        }<BR>    }</DIV>
<DIV> </DIV>
<DIV>    public class PrimitiveBaseShapeTableMapper : TableMapper<PrimitiveBaseShapeRowMapper, Guid><BR>    {<BR>        public PrimitiveBaseShapeTableMapper(DbConnectionPool connection, string tableName)<BR>            : base(connection, tableName)<BR>        {<BR>            RowMapperSchema<PrimitiveBaseShapeRowMapper> rowMapperSchema = new RowMapperSchema<PrimitiveBaseShapeRowMapper>();<BR>            m_schema = rowMapperSchema;</DIV>
<DIV>            m_keyFieldMapper = rowMapperSchema.AddMapping<Guid>("SceneObjectPartId",<BR>                                                                delegate(PrimitiveBaseShapeRowMapper shape) { return shape.SceneObjectPartId; },<BR>                                                                delegate(PrimitiveBaseShapeRowMapper shape, Guid value) { shape.SceneObjectPartId = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<byte>("PCode",<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PCode; },<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PCode = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<ushort>("PathBegin",<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathBegin; },<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathBegin = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<ushort>("PathEnd",<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathEnd; },<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathEnd = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<byte>("PathScaleX",<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleX; },<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleX = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<byte>("PathScaleY",<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleY; },<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleY = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<byte>("PathShearX",<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearX; },<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearX = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<byte>("PathShearY",<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearY; },<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearY = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<ushort>("ProfileBegin",<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileBegin; },<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileBegin = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<ushort>("ProfileEnd",<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileEnd; },<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileEnd = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<BluedogVector3>("Scale",<BR>                                                       delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.Scale; },<BR>                                                       delegate(PrimitiveBaseShapeRowMapper shape, BluedogVector3 value) { shape.Object.Scale = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<sbyte>("PathTaperX",<BR>                                              delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperX; },<BR>                                              delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperX = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<sbyte>("PathTaperY",<BR>                                              delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperY; },<BR>                                              delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperY = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<sbyte>("PathTwist",<BR>                                              delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwist; },<BR>                                              delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwist = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<sbyte>("PathRadiusOffset",<BR>                                              delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRadiusOffset; },<BR>                                              delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathRadiusOffset = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<byte>("PathRevolutions",<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRevolutions; },<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathRevolutions = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<sbyte>("PathTwistBegin",<BR>                                              delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwistBegin; },<BR>                                              delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwistBegin = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<byte>("PathCurve",<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathCurve; },<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathCurve = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<byte>("ProfileCurve",<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileCurve; },<BR>                                             delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.ProfileCurve = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<ushort>("ProfileHollow",<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileHollow; },<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileHollow = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<byte[]>("TextureEntry",<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.TextureEntry; },<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.TextureEntry = value; });</DIV>
<DIV>            rowMapperSchema.AddMapping<byte[]>("ExtraParams",<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ExtraParams; },<BR>                                               delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.ExtraParams = value; });            <BR>        }</DIV>
<DIV>        public override PrimitiveBaseShapeRowMapper FromReader(DataReader reader)<BR>        {<BR>            PrimitiveBaseShape shape = new PrimitiveBaseShape();</DIV>
<DIV>            PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper(m_schema, shape);<BR>            mapper.FillObject( reader );</DIV>
<DIV>            return mapper;<BR>        }</DIV>
<DIV>        public bool Update(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)<BR>        {<BR>            PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape);<BR>            return Update(sceneObjectPartId, mapper);<BR>        }</DIV>
<DIV>        public bool Add(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)<BR>        {<BR>            PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape);<BR>            return Add(mapper);<BR>        }</DIV>
<DIV>        private PrimitiveBaseShapeRowMapper CreateRowMapper(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)<BR>        {<BR>            PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper( m_schema, primitiveBaseShape );<BR>            mapper.SceneObjectPartId = sceneObjectPartId;<BR>            return mapper;<BR>        }<BR>    }<BR>}</DIV></BLOCKQUOTE></body>
</html>