private void SetProperty(object graph, string property, NodeModel document) { object value = null; bool customValue = false; var propertyInfo = graph._GetPropertyInfo(property); property = propertyInfo?.Name ?? property.ChangeCase(TextCase.PascalCase); if (graph is IPropertyValueSetter setter) { var done = setter.SetProperty(property, document, this); if (done) { return; } } if (graph is IPropertyValueFactory factory) { customValue = factory.CreateValue(property, document, this, out value); if (!customValue && value != null) { value = null; } } if (Is.Dictionary(graph)) { var keyType = TypeOf.DictionaryKey(graph); var key = Change.To(property, keyType); if (!customValue) { var valueType = TypeOf.DictionaryValue(graph); value = CreateGraph(document, valueType); } var dictionary = (IDictionary)graph; dictionary.Add(key, value); return; } if (propertyInfo == null) { throw new NoSuchPropertyException(graph.GetType(), property); } if (!customValue) { value = CreateGraph(document, propertyInfo.PropertyType); } graph._Set(property, value); }