From 01bb3d4f235424b1f72ab0c08d968d38a8deba45 Mon Sep 17 00:00:00 2001 From: Daniel Cronqvist Date: Mon, 2 Sep 2024 21:14:56 +0200 Subject: [PATCH] Add better default loader creation --- src/DotTiled/Serialization/Loader.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/DotTiled/Serialization/Loader.cs b/src/DotTiled/Serialization/Loader.cs index 8b4b9f0..7651c3e 100644 --- a/src/DotTiled/Serialization/Loader.cs +++ b/src/DotTiled/Serialization/Loader.cs @@ -32,11 +32,26 @@ public class Loader } /// - /// Creates a new instance of a with the default and . + /// Creates a new instance of a with the default and , and no available custom type definitions. /// - /// An optional collection of custom type definitions that can be used to resolve custom types in Tiled resources. /// A new instance of a . - public static Loader Default(IEnumerable customTypeDefinitions = null) => new Loader(new FileSystemResourceReader(), new DefaultResourceCache(), customTypeDefinitions ?? []); + public static Loader Default() => new Loader(new FileSystemResourceReader(), new DefaultResourceCache(), []); + + /// + /// Creates a new instance of a with the ability to override the default , , and custom type definitions. + /// + /// A reader that is able to read Tiled resources from a given path. + /// A cache that stores Tiled resources for faster retrieval and reuse. + /// A collection of custom type definitions that can be used to resolve custom types in Tiled resources. + /// + public static Loader DefaultWith( + IResourceReader resourceReader = null, + IResourceCache resourceCache = null, + IEnumerable customTypeDefinitions = null) => + new Loader( + resourceReader ?? new FileSystemResourceReader(), + resourceCache ?? new DefaultResourceCache(), + customTypeDefinitions ?? Array.Empty()); /// /// Loads a map from the given .