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() ...@@ -1222,7 +1222,7 @@ public override IEnumerable<string> GetDynamicMemberNames()
void IDictionary<string, object>.Add(string key, object value) void IDictionary<string, object>.Add(string key, object value)
{ {
throw new NotImplementedException(); data.Add(key, value);
} }
bool IDictionary<string, object>.ContainsKey(string key) bool IDictionary<string, object>.ContainsKey(string key)
...@@ -1237,7 +1237,7 @@ public override IEnumerable<string> GetDynamicMemberNames() ...@@ -1237,7 +1237,7 @@ public override IEnumerable<string> GetDynamicMemberNames()
bool IDictionary<string, object>.Remove(string key) bool IDictionary<string, object>.Remove(string key)
{ {
throw new NotImplementedException(); return data.Remove(key);
} }
bool IDictionary<string, object>.TryGetValue(string key, out object value) bool IDictionary<string, object>.TryGetValue(string key, out object value)
...@@ -1258,10 +1258,6 @@ public override IEnumerable<string> GetDynamicMemberNames() ...@@ -1258,10 +1258,6 @@ public override IEnumerable<string> GetDynamicMemberNames()
} }
set set
{ {
if (!data.ContainsKey(key))
{
throw new NotImplementedException();
}
data[key] = value; data[key] = value;
} }
} }
...@@ -1272,12 +1268,12 @@ public override IEnumerable<string> GetDynamicMemberNames() ...@@ -1272,12 +1268,12 @@ public override IEnumerable<string> GetDynamicMemberNames()
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item) void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item)
{ {
throw new NotImplementedException(); data.Add(item);
} }
void ICollection<KeyValuePair<string, object>>.Clear() void ICollection<KeyValuePair<string, object>>.Clear()
{ {
throw new NotImplementedException(); data.Clear();
} }
bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item) bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item)
...@@ -1302,7 +1298,7 @@ public override IEnumerable<string> GetDynamicMemberNames() ...@@ -1302,7 +1298,7 @@ public override IEnumerable<string> GetDynamicMemberNames()
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item) bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item)
{ {
throw new NotImplementedException(); return data.Remove(item);
} }
#endregion #endregion
...@@ -3060,7 +3056,7 @@ public ConstructorInfo FindConstructor(string[] names, Type[] types) ...@@ -3060,7 +3056,7 @@ public ConstructorInfo FindConstructor(string[] names, Type[] types)
/// <returns></returns> /// <returns></returns>
public SqlMapper.IMemberMap GetConstructorParameter(ConstructorInfo constructor, string columnName) public SqlMapper.IMemberMap GetConstructorParameter(ConstructorInfo constructor, string columnName)
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
/// <summary> /// <summary>
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
using System.Reflection; using System.Reflection;
using System.Dynamic; using System.Dynamic;
using System.ComponentModel; using System.ComponentModel;
using Microsoft.CSharp.RuntimeBinder;
#if POSTGRESQL #if POSTGRESQL
using Npgsql; using Npgsql;
#endif #endif
...@@ -2120,6 +2121,23 @@ public void TestMultiSelectWithSomeEmptyGrids() ...@@ -2120,6 +2121,23 @@ public void TestMultiSelectWithSomeEmptyGrids()
four[0].IsEqualTo(4); 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 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