Пример #1
0
 public override void FromToml(TomlObject tomlObject)
 {
     if (tomlObject != null)
     {
         if (tomlObject.TryGetValue <T>(out var tomlValue))
         {
             Value = tomlValue;
         }
         else
         {
             Log.Warn("Failed to read '{0}', got {1} with {2}", Key, tomlObject.ReadableTypeName, tomlObject.DumpToJson());
         }
     }
 }
Пример #2
0
        public override void FromToml(TomlObject tomlObject)
        {
            if (tomlObject == null)
            {
                return;
            }

            if (!tomlObject.TryGetValue <T>(out var tomlValue))
            {
                Log.Warn("Failed to read '{0}', got {1} with {2}", Key, tomlObject.ReadableTypeName, tomlObject.DumpToJson());
                return;
            }

            var validate = Validator?.Invoke(tomlValue) ?? R.Ok;

            if (!validate.Ok)
            {
                Log.Warn("Invalid value in '{0}', {1}", Key, validate.Error);
                return;
            }

            Value = tomlValue;
        }