public void SaveProperties(object objectToSave, object identifier, string prefix = null) { if (objectToSave == null) { return; } var type = objectToSave.GetType(); prefix = prefix ?? GetTypeName(type); var key = $"{identifier}{prefix}"; if (type.IsPrimitive || type == typeof(string) || type == typeof(decimal) || objectToSave is IEnumerable) { var propertyTypeDictionary = PropertyPatternDictionary.Instance(); if (!propertyTypeDictionary.ContainsKey(prefix)) { propertyTypeDictionary.Add(prefix, type.Name); } var propertyDictionary = PropertyDictionary.Instance(); if (propertyDictionary.ContainsKey(key)) { propertyDictionary[key] = GetValue(objectToSave); } else { propertyDictionary.Add(key, GetValue(objectToSave)); } } else { foreach (var property in type.GetProperties()) { var immediatePrefix = $"{prefix}{property.Name}"; SaveProperties(property.GetValue(objectToSave), identifier, immediatePrefix); } } }
public List <string> GetPropertyPatternKeys() { return(PropertyPatternDictionary.Instance().Keys.ToList()); }