public Dictionary <string, object> Serialize(IShapeObject shape) { shape = shape ?? throw new ArgumentNullException(nameof(shape)); var shapeType = shape.GetType(); var shapeProperty = propertyCache.GetProperties(shapeType); var result = shapeProperty.Values.ToDictionary(k => k.PropName, v => v.Getter.DynamicInvoke(shape)); return(result); }
public void Deserialize(IShapeObject shape, Dictionary <string, object> shapeState) { shape = shape ?? throw new ArgumentNullException(nameof(shape)); var shapeType = shape.GetType(); var props = propertyCache.GetProperties(shapeType); foreach ((string propName, object value) in shapeState) { props[propName].Setter.DynamicInvoke(shape, value); } }