Ugly workaround for mono-1.2.6 compile failure in TribalMedia code.
Future versions of mono should not need this. Please revert if this makes you cry.ThreadPoolClientBranch
parent
582d0a29d5
commit
b8820a75ef
|
@ -123,12 +123,11 @@ namespace TribalMedia.Framework.Data
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetValue(TPrimaryKey primaryKey, out TRowMapper value)
|
// HACK: This is a temporary function used by TryGetValue().
|
||||||
{
|
// Due to a bug in mono 1.2.6, delegate blocks cannot contain
|
||||||
TRowMapper result = default(TRowMapper);
|
// a using() block. This has been fixed in SVN, so the next
|
||||||
bool success = false;
|
// mono release should work.
|
||||||
|
private void TryGetConnectionValue(DbConnection connection, TPrimaryKey primaryKey, ref TRowMapper result, ref bool success)
|
||||||
WithConnection(delegate(DbConnection connection)
|
|
||||||
{
|
{
|
||||||
using (
|
using (
|
||||||
DbCommand command =
|
DbCommand command =
|
||||||
|
@ -147,6 +146,16 @@ namespace TribalMedia.Framework.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetValue(TPrimaryKey primaryKey, out TRowMapper value)
|
||||||
|
{
|
||||||
|
TRowMapper result = default(TRowMapper);
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
|
WithConnection(delegate(DbConnection connection)
|
||||||
|
{
|
||||||
|
TryGetConnectionValue(connection, primaryKey, ref result, ref success);
|
||||||
});
|
});
|
||||||
|
|
||||||
value = result;
|
value = result;
|
||||||
|
@ -154,18 +163,27 @@ namespace TribalMedia.Framework.Data
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HACK: This is a temporary function used by Remove().
|
||||||
|
// Due to a bug in mono 1.2.6, delegate blocks cannot contain
|
||||||
|
// a using() block. This has been fixed in SVN, so the next
|
||||||
|
// mono release should work.
|
||||||
|
protected virtual void TryDelete(DbConnection connection, TPrimaryKey id, ref int deleted)
|
||||||
|
{
|
||||||
|
using (
|
||||||
|
DbCommand command =
|
||||||
|
CreateDeleteCommand(connection, KeyFieldMapper.FieldName, id))
|
||||||
|
{
|
||||||
|
deleted = command.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual bool Remove(TPrimaryKey id)
|
public virtual bool Remove(TPrimaryKey id)
|
||||||
{
|
{
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
|
|
||||||
WithConnection(delegate(DbConnection connection)
|
WithConnection(delegate(DbConnection connection)
|
||||||
{
|
{
|
||||||
using (
|
TryDelete(connection, id, ref deleted);
|
||||||
DbCommand command =
|
|
||||||
CreateDeleteCommand(connection, KeyFieldMapper.FieldName, id))
|
|
||||||
{
|
|
||||||
deleted = command.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (deleted == 1)
|
if (deleted == 1)
|
||||||
|
@ -178,7 +196,6 @@ namespace TribalMedia.Framework.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DbCommand CreateDeleteCommand(DbConnection connection, string fieldName, TPrimaryKey primaryKey)
|
public DbCommand CreateDeleteCommand(DbConnection connection, string fieldName, TPrimaryKey primaryKey)
|
||||||
{
|
{
|
||||||
string table = TableName;
|
string table = TableName;
|
||||||
|
@ -196,16 +213,25 @@ namespace TribalMedia.Framework.Data
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HACK: This is a temporary function used by Update().
|
||||||
|
// Due to a bug in mono 1.2.6, delegate blocks cannot contain
|
||||||
|
// a using() block. This has been fixed in SVN, so the next
|
||||||
|
// mono release should work.
|
||||||
|
protected void TryUpdate(DbConnection connection, TPrimaryKey primaryKey, TRowMapper value, ref int updated)
|
||||||
|
{
|
||||||
|
using (DbCommand command = CreateUpdateCommand(connection, value, primaryKey))
|
||||||
|
{
|
||||||
|
updated = command.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual bool Update(TPrimaryKey primaryKey, TRowMapper value)
|
public virtual bool Update(TPrimaryKey primaryKey, TRowMapper value)
|
||||||
{
|
{
|
||||||
int updated = 0;
|
int updated = 0;
|
||||||
|
|
||||||
WithConnection(delegate(DbConnection connection)
|
WithConnection(delegate(DbConnection connection)
|
||||||
{
|
{
|
||||||
using (DbCommand command = CreateUpdateCommand(connection, value, primaryKey))
|
TryUpdate(connection, primaryKey, value, ref updated);
|
||||||
{
|
|
||||||
updated = command.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (updated == 1)
|
if (updated == 1)
|
||||||
|
@ -218,16 +244,25 @@ namespace TribalMedia.Framework.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HACK: This is a temporary function used by Add().
|
||||||
|
// Due to a bug in mono 1.2.6, delegate blocks cannot contain
|
||||||
|
// a using() block. This has been fixed in SVN, so the next
|
||||||
|
// mono release should work.
|
||||||
|
protected void TryAdd(DbConnection connection, TRowMapper value, ref int added)
|
||||||
|
{
|
||||||
|
using (DbCommand command = CreateInsertCommand(connection, value))
|
||||||
|
{
|
||||||
|
added = command.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual bool Add(TRowMapper value)
|
public virtual bool Add(TRowMapper value)
|
||||||
{
|
{
|
||||||
int added = 0;
|
int added = 0;
|
||||||
|
|
||||||
WithConnection(delegate(DbConnection connection)
|
WithConnection(delegate(DbConnection connection)
|
||||||
{
|
{
|
||||||
using (DbCommand command = CreateInsertCommand(connection, value))
|
TryAdd(connection, value, ref added);
|
||||||
{
|
|
||||||
added = command.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (added == 1)
|
if (added == 1)
|
||||||
|
|
|
@ -99,7 +99,6 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
<!--
|
|
||||||
<Project name="TribalMedia.Framework.Data" path="ThirdParty/TribalMedia/TribalMedia.Framework.Data" type="Library">
|
<Project name="TribalMedia.Framework.Data" path="ThirdParty/TribalMedia/TribalMedia.Framework.Data" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
|
@ -122,7 +121,6 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
-->
|
|
||||||
<Project name="OpenSim.Framework.Data" path="OpenSim/Framework/Data" type="Library">
|
<Project name="OpenSim.Framework.Data" path="OpenSim/Framework/Data" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
|
|
Loading…
Reference in New Issue