/// <summary> /// 将本对象的用户配置值保存到内存中或持久化的配置文件中 /// </summary> public void Save(bool persistent = false) { if (CurrentContextDict != null) { foreach (string propertyName in CurrentContextDict.Keys.ToList()) { string[] propertyNames = propertyName.Split('.'); object obj = propertyNames.Length == 1 ? ContextObject : FindObject(propertyNames); obj = RefHelper.GetValue(obj, propertyNames[propertyNames.Length - 1]); if (obj == null) { CurrentContextDict.Remove(propertyName); } else if (obj.GetType() == typeof(String) || !obj.GetType().IsClass) { CurrentContextDict[propertyName] = new TypeAndValue { TypeName = obj.GetType().AssemblyQualifiedName, Value = CommOp.ToFullStr(obj) }; } else { CurrentContextDict[propertyName] = new TypeAndValue { TypeName = obj.GetType().AssemblyQualifiedName, Value = JsonHelper.ToJson(obj) }; } } } if (persistent) { SaveAllToPersistent(); } }