/// <inheritdoc /> public override void DataWriteFunction <T>(string name, T defaultValue, WriteFunctionDelegate <T> func, bool alwaysWrite = false) { if (Reading) { return; } var value = func.Invoke(); // don't write if value is null or default if (!alwaysWrite && IsValueDefault(name, value, defaultValue, WithFormat <T> .NoFormat)) { return; } var key = name; var val = value == null?TypeToNode(defaultValue !) : TypeToNode(value); // write the concrete type tag if (typeof(T).IsAbstract || typeof(T).IsInterface) { var concreteType = value == null ? defaultValue !.GetType() : value.GetType(); val.Tag = $"!type:{concreteType.Name}"; } WriteMap !.Add(key, val); }
/// <inheritdoc /> public override void DataWriteFunction <T>(string name, T defaultValue, WriteFunctionDelegate <T> func, bool alwaysWrite = false) { if (Reading) { return; } var value = func.Invoke(); // don't write if value is null or default if (!alwaysWrite && IsValueDefault(name, value, defaultValue)) { return; } var key = name; var val = value == null?TypeToNode(defaultValue) : TypeToNode(value); WriteMap.Add(key, val); }
/// <inheritdoc /> public override void DataWriteFunction <T>(string name, T defaultValue, WriteFunctionDelegate <T> func, bool alwaysWrite = false) { if (Reading) { return; } var value = func.Invoke(); // don't write if value is null or default if (!alwaysWrite && IsValueDefault(name, value, defaultValue, WithFormat <T> .NoFormat)) { return; } var key = name; var val = value == null?TypeToNode(defaultValue !) : TypeToNode(value); // write the concrete type tag AssignTag(typeof(T), value, defaultValue, val); WriteMap !.Add(key, val); }