From fefd489dcc170a11698d05236f2f5241c9b0e12a Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Mon, 30 Mar 2020 00:02:29 -0500 Subject: [PATCH] Documented new things --- .../Config/Stores/CustomObjectConverter.cs | 46 +++++++++++++++++-- IPA.Loader/Logging/StandardLogger.cs | 4 ++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/IPA.Loader/Config/Stores/CustomObjectConverter.cs b/IPA.Loader/Config/Stores/CustomObjectConverter.cs index 20465742..e361a3e2 100644 --- a/IPA.Loader/Config/Stores/CustomObjectConverter.cs +++ b/IPA.Loader/Config/Stores/CustomObjectConverter.cs @@ -72,7 +72,7 @@ namespace IPA.Config.Stores.Converters /// the deserialized value /// public override T FromValue(Value value, object parent) - => impl.FromValue(value, parent); + => Deserialize(value, parent); /// /// Serializes into a structure, given . @@ -82,9 +82,14 @@ namespace IPA.Config.Stores.Converters /// the tree that represents /// public override Value ToValue(T obj, object parent) - => impl.ToValue(obj, parent); + => Serialize(obj, parent); } + /// + /// A for custom value types, serialized identically to the reference types serialized with + /// . + /// + /// the type of the value to convert public class CustomValueTypeConverter : ValueConverter where T : struct { private static readonly GeneratedStoreImpl.SerializeObject serialize @@ -92,11 +97,44 @@ namespace IPA.Config.Stores.Converters private static readonly GeneratedStoreImpl.DeserializeObject deserialize = GeneratedStoreImpl.GetDeserializerDelegate(); - public override T FromValue(Value value, object parent) + /// + /// Deserializes into a with the given . + /// + /// the to deserialize + /// the parent object that will own the deserialized value + /// the deserialized value + /// + public static T Deserialize(Value value, object parent) => deserialize(value, parent); - public override Value ToValue(T obj, object parent) + /// + /// Serializes into a corresponding structure. + /// + /// the object to serialize + /// the tree that represents + /// + public static Value Serialize(T obj) => serialize(obj); + + /// + /// Deserializes into a with the given . + /// + /// the to deserialize + /// the parent object that will own the deserialized value + /// the deserialized value + /// + public override T FromValue(Value value, object parent) + => Deserialize(value, parent); + + /// + /// Serializes into a structure, given . + /// + /// the object to serialize + /// the parent object that owns + /// the tree that represents + /// + public override Value ToValue(T obj, object parent) + => Serialize(obj); } } diff --git a/IPA.Loader/Logging/StandardLogger.cs b/IPA.Loader/Logging/StandardLogger.cs index bdf89587..21702e8d 100644 --- a/IPA.Loader/Logging/StandardLogger.cs +++ b/IPA.Loader/Logging/StandardLogger.cs @@ -268,6 +268,10 @@ namespace IPA.Logging [ThreadStatic] private static bool? isOnLoggerThread = null; + /// + /// Whether or not the calling thread is the logger thread. + /// + /// if the current thread is the logger thread, otherwise public static bool IsOnLoggerThread => isOnLoggerThread ??= Thread.CurrentThread.ManagedThreadId == logThread.ManagedThreadId; private static readonly ManualResetEventSlim logWaitEvent = new ManualResetEventSlim(true);