internal static IEnumerable <PropertyInfo> GetProperties(IShareable obj) { var type = obj.GetType(); if (!_classProperties.ContainsKey(type)) { _classProperties[type] = type.GetProperties().Where(p => (typeof(IShareable).IsAssignableFrom(p.PropertyType))); } return(_classProperties[type]); }
internal static void Build(IShareable obj, Cache cache) { foreach (var prop in GetProperties(obj.GetType())) { if (!cache.ContainsKey(prop.PropertyType)) { IShareable shareable = New(prop.PropertyType); cache[prop.PropertyType] = shareable; Build(shareable, cache); } SetPropertyValue(obj, prop, cache[prop.PropertyType]); prop.SetValue(obj, cache[prop.PropertyType]); } }