Как изменить «MyConverter» после обновления NJsonSchema с 10.x до 11.0.2C#

Место общения программистов C#
Anonymous
Как изменить «MyConverter» после обновления NJsonSchema с 10.x до 11.0.2

Сообщение Anonymous »

У меня есть класс, который наследует JsonInheritanceConverter, как показано ниже:

Код: Выделить всё

public class MyConverter : JsonInheritanceConverter
{
private const string DtoSuffix = "Dto";

public JsonInheritanceDtoConverter(string name) : base(name)
{
}

public Type GetDiscriminatorType(Type objectType, string discriminatorValue)
{
return GetDiscriminatorType(null, objectType, discriminatorValue);
}

public override string GetDiscriminatorValue(Type type)
{
return RemoveFromEnd(type.Name, DtoSuffix);
}

protected override Type GetDiscriminatorType(
JObject jObject,
Type objectType,
string discriminatorValue)
{
return base.GetDiscriminatorType(jObject, objectType, discriminatorValue + DtoSuffix);
}

public static string RemoveFromEnd(string s, string suffix)
{
return s.Substring(0, s.Length - suffix.Length);
}
}
}

Однако после обновления NJsonSchema до версии 11.0.2 JsonInheritanceConverter становится классом шаблона, а защищенный метод GetDiscriminatorType становится

Код: Выделить всё

GetDiscriminatorType(
JsonElement jObject,
Type objectType,
string discriminatorValue)
Как мне изменить MyConverter, чтобы обеспечить правильное наследование от JsonInheritanceConverter?

Подробнее здесь: https://stackoverflow.com/questions/790 ... -to-11-0-2

Вернуться в «C#»