Simplify load fix

This commit is contained in:
AbdulmanovAI
2025-10-29 16:38:42 +04:00
parent fe3b681c66
commit 00aa9998c7

View File

@@ -78,23 +78,15 @@ namespace SlaveMatrix
[NonSerialized] [NonSerialized]
public Type ThisType; public Type ThisType;
// Храним только имя типа (можно AQN) //Some how fixes saves (thx GPT)
[OptionalField] private string _thisTypeName;
[OnSerializing] //So how I am understend it (description)
private void OnSerializing(StreamingContext _) //This Type is empty on deserialization because Type is not serializable
{ //We need just init it after deserialization
_thisTypeName = ThisType?.AssemblyQualifiedName
?? GetType().AssemblyQualifiedName;
}
[OnDeserialized] [OnDeserialized]
private void OnDeserialized(StreamingContext _) private void OnDeserialized(StreamingContext _) => ThisType = GetType();
{
ThisType = _thisTypeName != null
? Type.GetType(_thisTypeName, throwOnError: false) ?? GetType()
: GetType();
}
public virtual Ele GetEle(double DisUnit, Med Med, ) public virtual Ele GetEle(double DisUnit, Med Med, )
{ {