Files
Umbraco-CMS/src/Umbraco.Core/Dynamics/DynamicDictionary.cs
Shannon Deminick 5213d6de5c renamed IContentStore to IPublishedContentStore. Migrating DynamicNode to Umbraco.Core and cleaning up it's supported codebase.
Starting writing a few unit tests for the new DynamicNode codebase. Will of course leave the original DynamicNode stuff in its
current place for backwards compatibility but will deprecate many of the classes which will call the new ones.
2012-08-17 04:27:47 +06:00

39 lines
1.1 KiB
C#

using System.Collections.Generic;
using System.Dynamic;
namespace Umbraco.Core.Dynamics
{
public class DynamicDictionary : DynamicObject
{
readonly Dictionary<string, object> _dictionary;
public DynamicDictionary(Dictionary<string, object> sourceItems)
{
_dictionary = sourceItems;
}
public override bool TrySetMember(SetMemberBinder binder, object value)
{
if (_dictionary.ContainsKey(binder.Name))
{
_dictionary[binder.Name.ToLower()] = value;
}
else
{
_dictionary.Add(binder.Name.ToLower(), value);
}
return true;
}
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (_dictionary != null)
{
if (_dictionary.TryGetValue(binder.Name.ToLower(), out result))
{
return true;
}
}
result = null;
return true;
}
}
}