Aurumaker72
Aurumaker72
CC#
Created by Aurumaker72 on 4/15/2023 in #help
❔ Avalonia ComboBox SelectedValuePath
<ComboBox SelectedValue="{Binding Path=SomeValue, Mode=TwoWay}" SelectedValuePath="Tag">
<ComboBoxItem Tag="x">A</ComboBoxItem>
<ComboBoxItem Tag="y">B</ComboBoxItem>
</ComboBox>
<ComboBox SelectedValue="{Binding Path=SomeValue, Mode=TwoWay}" SelectedValuePath="Tag">
<ComboBoxItem Tag="x">A</ComboBoxItem>
<ComboBoxItem Tag="y">B</ComboBoxItem>
</ComboBox>
Is there a way to do this in Avalonia?
7 replies
CC#
Created by Aurumaker72 on 1/17/2023 in #help
❔ Newtonsoft.JSON Nested Json deserialized incorrectly
I'm serializing and transmitting the following class
[JsonObject(MemberSerialization.OptIn)]
public class Message
{
[JsonProperty]
public Types Type { get; }

[JsonProperty]
public string Json { get; }
}
[JsonObject(MemberSerialization.OptIn)]
public class Message
{
[JsonProperty]
public Types Type { get; }

[JsonProperty]
public string Json { get; }
}
The Json property contains a serialized object of relevance to the Type e.g.: If Type is DoMove, the Json is expected to be a serialized point. Serializing this works fine and the nested json is escaped properly, but deserializing just skips the json. It works with the Type, but just doesn't touch the nested json. First and foremost, I'm looking for a workaround to this, alternatively I'm looking for suggestions to improve this entire system... because it sucks.
4 replies
CC#
Created by Aurumaker72 on 11/26/2022 in #help
✅ Newtonsoft.JSON correctly serializes data but erroneously leaves out arrays during deserialization
My simplified code is as follows:
public class Building
{
public string Key;

public Building(string key)
{
Key = key;
}
}
public class Building
{
public string Key;

public Building(string key)
{
Key = key;
}
}
public class Game
{
public Game(object _)
{
buildings = new Building[]
{
new Building("extractor")
};
}
private Building[] buildings;

public Building[] Buildings => buildings;
}
public class Game
{
public Game(object _)
{
buildings = new Building[]
{
new Building("extractor")
};
}
private Building[] buildings;

public Building[] Buildings => buildings;
}
After serializing the Game class, I end up with:
{
"Buildings": [
{
"Key": "extractor"
}
]
}
{
"Buildings": [
{
"Key": "extractor"
}
]
}
This is correct, but deserializing the Game class from this json results in this data:
Game
-> buildings: null
Game
-> buildings: null
The buildings array has been lost during deserialization. This same behaviour happens with the built-in JsonSerializer.
44 replies