<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Hi back,<BR>
 <BR>
Well I managed to get something running with Asset server (partially... because I need to implement a Save operation that would update or insert depending on the asset to exist or not - The asset server is trying to insert existing assets, which leads to a key violation during insert) .<BR>
 <BR>
I had to add a Set accessor to Schema in TableMapper, put an empty constructor to the DatabaseMapper (which I specialized with a SQLiteDatabaseMapper) so it can be instanciated using the current plugin pattern, then add a ConnectionString property. Does it makes sense ?<BR>
 <BR>
Although I managed to get something running, I think I am not finish catching up with this pattern. I suppose it is a question of habits. I struggled to get things correctly setup and instanciated, while trying to avoid to change too much things :)<BR>
 <BR>
Laurent.<BR>

<HR id=EC_stopSpelling>
<BR>
From: grumly57@hotmail.com<BR>To: opensim-dev@lists.berlios.de<BR>Date: Mon, 14 Jan 2008 14:31:21 +0100<BR>Subject: Re: [Opensim-dev] further db thoughts<BR><BR>
<META content="Microsoft SafeHTML" name=Generator>
<STYLE>
.ExternalClass .EC_hmmessage P
{padding:0px;}
.ExternalClass EC_body.hmmessage
{font-size:10pt;font-family:Tahoma;}
</STYLE>
This is just what I needed :-) a piece of code + some guidance.<BR> <BR>Elegant does not mean "simple"... However, this is a very interresting approach.<BR>I will to get Assets persistence working this way.<BR> <BR>Thanks a lot,<BR>Laurent.<BR><BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR id=EC_EC_stopSpelling>
From: stefan@tribalmedia.se<BR>To: opensim-dev@lists.berlios.de<BR>Date: Mon, 14 Jan 2008 11:31:50 +0100<BR>Subject: Re: [Opensim-dev] further db thoughts<BR><BR>
<STYLE>
.ExternalClass .EC_hmmessage P
{padding:0px;}
.ExternalClass EC_body.hmmessage
{font-size:10pt;font-family:Tahoma;}
</STYLE>

<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></BLOCKQUOTE><BR>
<HR>
Téléchargez gratuitement <A href="http://www.windowslive.fr/majmessenger.asp" target=_blank>Messenger 2008</A> </BLOCKQUOTE><br /><hr />Windows Live Messenger 2008 vient de sortir, découvrez son nouveau design !  <a href='http://www.windowslive.fr/majmessenger.asp' target='_new'>Téléchargez gratuitement Messenger 2008</a></body>
</html>