mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-05-09 03:56:04 +03:00
Make custom types optional
This commit is contained in:
parent
67876c6532
commit
8c9068cc97
21 changed files with 189 additions and 59 deletions
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using DotTiled.Serialization;
|
||||
|
@ -57,12 +56,12 @@ public partial class MapParser : Node2D
|
|||
return templateReader.ReadTemplate();
|
||||
}
|
||||
|
||||
private static ICustomTypeDefinition ResolveCustomType(string name)
|
||||
private static Optional<ICustomTypeDefinition> ResolveCustomType(string name)
|
||||
{
|
||||
ICustomTypeDefinition[] allDefinedTypes =
|
||||
[
|
||||
new CustomClassDefinition() { Name = "a" },
|
||||
];
|
||||
return allDefinedTypes.FirstOrDefault(type => type.Name == name) ?? throw new InvalidOperationException();
|
||||
return allDefinedTypes.FirstOrDefault(ctd => ctd.Name == name) is ICustomTypeDefinition ctd ? new Optional<ICustomTypeDefinition>(ctd) : Optional<ICustomTypeDefinition>.Empty;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue