You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class Pest
{
public string Name { get; set; }
public string Description { get; set; }
}
public class Pet
{
public string Name { get; set; }
public string Description { get; set; }
public List<Pest> Pests { get; set; }
}
public class Inhabitant
{
public string Name { get; set; }
public string Description { get; set; }
public List<Pet> Pets { get; set; }
}
public class Planet
{
public string Name { get; set; }
public List<Inhabitant> Inhabitants { get; set; }
}
public class Galaxy
{
public List<Planet> Planets { get; set; }
}
internal class Program
{
static void Main(string[] args)
{
Galaxy MilkyWay = new Galaxy();
MilkyWay.Planets = new List<Planet>();
Planet Earth = new Planet();
Earth.Name = "Earth";
Earth.Inhabitants = new List<Inhabitant>();
Inhabitant Mammals = new Inhabitant();
Mammals.Name = "Humans";
Mammals.Description = "xyz";
Mammals.Pets = new List<Pet>();
Pest Flea = new Pest();
Flea.Name = "Fleas";
Flea.Description = "abc";
Pet Dogs = new Pet();
Dogs.Name = "Dogs";
Dogs.Description = "xyzzy";
Dogs.Pests = new List<Pest>();
Dogs.Pests.Add(Flea);
Pet Cats = new Pet();
Cats.Name = "Cats";
Cats.Description = "xyzzy";
Cats.Pests = new List<Pest>();
Cats.Pests.Add(Flea);
Mammals.Pets.Add(Dogs);
Mammals.Pets.Add(Cats);
Earth.Inhabitants.Add(Mammals);
MilkyWay.Planets.Add(Earth);
Planet Mars = new Planet();
Mars.Name = "Mars";
Mars.Inhabitants = new List<Inhabitant>();
Inhabitant GrayOnes = new Inhabitant();
GrayOnes.Name = "Little Gray Men";
GrayOnes.Description = "xyz";
GrayOnes.Pets = new List<Pet>();
Pet MartianBrainSlug = new Pet();
MartianBrainSlug.Name = "Martian Brain Slug";
MartianBrainSlug.Description = "xyzzy";
GrayOnes.Pets.Add(MartianBrainSlug);
Mars.Inhabitants.Add(GrayOnes);
MilkyWay.Planets.Add(Mars);
string TOML = TomletMain.TomlStringFrom(MilkyWay);
}
}
The output looks like this:
[[Planets]]
Name = "Earth"
[[Planets.Inhabitants]]
Name = "Humans"
Description = "xyz"
[["Planets.Inhabitants".Pets]]
Name = "Dogs"
Description = "xyzzy"
Pests = [
{ Name = "Fleas", Description = "abc" },
]
[["Planets.Inhabitants".Pets]]
Name = "Cats"
Description = "xyzzy"
Pests = [
{ Name = "Fleas", Description = "abc" },
]
[[Planets]]
Name = "Mars"
[[Planets.Inhabitants]]
Name = "Little Gray Men"
Description = "xyz"
Pets = [
{ Name = "Martian Brain Slug", Description = "xyzzy" },
]
Quotes seem unnecessary (if they are stripped Tomlet successfully deserializes the document).
There seem to be 2 extra blank lines before Mars and 1 after it.
The text was updated successfully, but these errors were encountered:
With the following code:
The output looks like this:
The text was updated successfully, but these errors were encountered: