From cf129d451c15e151e890e5304c5cab46b3b44368 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sat, 14 Dec 2019 15:58:04 -0600 Subject: [PATCH] Added Converters file --- IPA.Loader/Config/Stores/Converters.cs | 38 ++++++++++++++++++++++++++ IPA.Loader/IPA.Loader.csproj | 1 + 2 files changed, 39 insertions(+) create mode 100644 IPA.Loader/Config/Stores/Converters.cs diff --git a/IPA.Loader/Config/Stores/Converters.cs b/IPA.Loader/Config/Stores/Converters.cs new file mode 100644 index 00000000..e56d3308 --- /dev/null +++ b/IPA.Loader/Config/Stores/Converters.cs @@ -0,0 +1,38 @@ +using IPA.Config.Data; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IPA.Config.Stores.Converters +{ + /// + /// Provides utility functions for custom converters. + /// + public static class Converter + { + /// + /// Gets the integral value of a , coercing a if necessary, + /// or if is not an or . + /// + /// the to get the integral value of + /// the integral value of , or + public static long? IntValue(Value val) + => val is Integer inte ? inte.Value : + val is FloatingPoint fp ? fp.AsInteger()?.Value : + null; + /// + /// Gets the floaing point value of a , coercing an if necessary, + /// or if is not an or . + /// + /// the to get the floaing point value of + /// the floaing point value of , or + public static decimal? FloatValue(Value val) + => val is FloatingPoint fp ? fp.Value : + val is Integer inte ? inte.AsFloat()?.Value : + null; + } + + +} diff --git a/IPA.Loader/IPA.Loader.csproj b/IPA.Loader/IPA.Loader.csproj index 315b9842..0743dc85 100644 --- a/IPA.Loader/IPA.Loader.csproj +++ b/IPA.Loader/IPA.Loader.csproj @@ -95,6 +95,7 @@ +