Commit f390f72e authored by Marc Gravell's avatar Marc Gravell

Implemented missing dictionary methods on FastExpando

parent dc1d0270
......@@ -1222,7 +1222,7 @@ public override IEnumerable<string> GetDynamicMemberNames()
void IDictionary<string, object>.Add(string key, object value)
{
throw new NotImplementedException();
data.Add(key, value);
}
bool IDictionary<string, object>.ContainsKey(string key)
......@@ -1237,7 +1237,7 @@ public override IEnumerable<string> GetDynamicMemberNames()
bool IDictionary<string, object>.Remove(string key)
{
throw new NotImplementedException();
return data.Remove(key);
}
bool IDictionary<string, object>.TryGetValue(string key, out object value)
......@@ -1258,10 +1258,6 @@ public override IEnumerable<string> GetDynamicMemberNames()
}
set
{
if (!data.ContainsKey(key))
{
throw new NotImplementedException();
}
data[key] = value;
}
}
......@@ -1272,12 +1268,12 @@ public override IEnumerable<string> GetDynamicMemberNames()
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item)
{
throw new NotImplementedException();
data.Add(item);
}
void ICollection<KeyValuePair<string, object>>.Clear()
{
throw new NotImplementedException();
data.Clear();
}
bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item)
......@@ -1302,7 +1298,7 @@ public override IEnumerable<string> GetDynamicMemberNames()
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item)
{
throw new NotImplementedException();
return data.Remove(item);
}
#endregion
......@@ -3060,7 +3056,7 @@ public ConstructorInfo FindConstructor(string[] names, Type[] types)
/// <returns></returns>
public SqlMapper.IMemberMap GetConstructorParameter(ConstructorInfo constructor, string columnName)
{
throw new NotImplementedException();
throw new NotSupportedException();
}
/// <summary>
......
......@@ -11,6 +11,7 @@
using System.Reflection;
using System.Dynamic;
using System.ComponentModel;
using Microsoft.CSharp.RuntimeBinder;
#if POSTGRESQL
using Npgsql;
#endif
......@@ -2120,6 +2121,23 @@ public void TestMultiSelectWithSomeEmptyGrids()
four[0].IsEqualTo(4);
}
}
[ActiveTest]
public void TestDynamicMutation()
{
var obj = connection.Query("select 1 as [a], 2 as [b], 3 as [c]").Single();
((int)obj.a).IsEqualTo(1);
IDictionary<string,object> dict = obj;
dict.Remove("a");
try
{
((int)obj.a).IsEqualTo(1);
throw new InvalidOperationException("should have thrown");
}
catch (RuntimeBinderException)
{
// pass
}
}
class TransactedConnection : IDbConnection
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment