private static IDictionary <string, object> CreateDynamicPropertiesContainer(Type type, ITypeCache typeCache, object instance, string dynamicPropertiesContainerName) { var property = typeCache.GetNamedProperty(type, dynamicPropertiesContainerName); if (property == null) { throw new ArgumentException($"Type {type} does not have property {dynamicPropertiesContainerName} "); } if (!typeCache.IsTypeAssignableFrom(typeof(IDictionary <string, object>), property.PropertyType)) { throw new InvalidOperationException($"Property {dynamicPropertiesContainerName} must implement IDictionary<string,object> interface"); } var dynamicProperties = new Dictionary <string, object>(); property.SetValue(instance, dynamicProperties, null); return(dynamicProperties); }