17 using System.Collections.Generic;
19 using System.Linq.Expressions;
20 using System.Reflection;
32 private static readonly MethodInfo SetPropertyMethodInfo = typeof(
DynamicData).GetMethod(
"SetProperty");
33 private static readonly MethodInfo GetPropertyMethodInfo = typeof(
DynamicData).GetMethod(
"GetProperty");
35 private readonly IDictionary<string, object> _snakeNameStorage =
new Dictionary<string, object>();
36 private readonly IDictionary<string, object> _storage =
new Dictionary<string, object>();
55 var snakeName = name.ToSnakeCase();
56 name = name.LazyToLower();
60 if (value is PyObject pyobject)
62 Time = pyobject.As<DateTime>();
66 Time = (DateTime)value;
69 else if (name ==
"endtime" || name ==
"end_time")
71 if (value is PyObject pyobject)
73 EndTime = pyobject.As<DateTime>();
80 else if (name ==
"value")
82 if (value is PyObject pyobject)
84 Value = pyobject.As<decimal>();
88 Value = (decimal)value;
91 else if (name ==
"symbol")
99 if (value is PyObject pyobject)
110 _storage[name] = value;
111 if (snakeName != name)
113 _snakeNameStorage[snakeName] = value;
125 name = name.ToLowerInvariant();
132 if (name ==
"endtime")
140 if (name ==
"symbol")
150 if (!_storage.TryGetValue(name, out value) && !_snakeNameStorage.TryGetValue(name, out value))
153 throw new KeyNotFoundException(
154 $
"Property with name \'{name}\' does not exist. Properties: Time, Symbol, Value {string.Join(",
", _storage.Keys)}"
169 return _storage.ContainsKey(name.ToLowerInvariant());
192 foreach (var kvp
in _storage)
195 clone._storage.Add(kvp);