Class Config
- Namespace
- Dec
- Assembly
- dec.dll
Contains global configuration data that may be needed before parsing. Initialize as soon as possible.
public static class Config
- Inheritance
-
objectConfig
Fields
ConverterFactory
A factory function that can be used to provide custom converters.
public static Func<Type, Converter> ConverterFactory
Field Value
Remarks
This is a tool of last resort; in most cases you should just be inheriting from ConverterString'1 et al. This is intended for converters from non-public classes, which can be access through (ab)use of reflection.
CultureInfo
The culture to use for parsing and writing values.
public static CultureInfo CultureInfo
Field Value
Remarks
This must be set statically, rather than loaded from the user's system, or parsing might break unpredictably. Recommend leaving this set to InvariantCulture for compatibility with the general Dec ecosystem; other options may have bugs (but report them and I'll fix them!)
Changing this while Dec is running is undefined behavior. Don't do that. Dec may be unable to read files written under a different CultureInfo; if you don't want that to be a problem, well, choose today, and choose wisely.
(just leave it set to its default for christ's sake)
DefaultHandlerShowConfigOnException
Tells the default handlers to attach a note to every exception saying that this behavior can be changed.
public static bool DefaultHandlerShowConfigOnException
Field Value
Remarks
Ignored if you're not using the default handlers.
DefaultHandlerThrowExceptions
Tells the default handlers when to throw exceptions.
public static Config.DefaultExceptionBehavior DefaultHandlerThrowExceptions
Field Value
Remarks
Ignored if you're not using the default handlers.
Dec is intended to work without exceptions; it's good at recovering from errors. This is very important if you have mods, as mods frequently have minor conflicts.
However, many developers don't configure the error reporting when first installing the library, often running into bizarre issues because of it.
This is set to be as loud and intrusive as possible just to get developers over that initial hump. I strongly recommend changing this to DefaultExceptionBehavior.Never, then ensuring that your errors and warnings are shown in a place you can't miss (like a popup or a modal dialog.)
Properties
ErrorHandler
Callback for error messages.
public static Action<string> ErrorHandler { get; set; }
Property Value
Remarks
This should be made unmissably visible to developers and testers, ideally with a popup or a modal dialog.
Can be made to throw an exception. If it does, the exception will propagate to the caller. Otherwise, dec will attempt to recover from the error.
If you're using any multithreading, this must be threadsafe.
ExceptionHandler
Callback for unhandled exceptions.
public static Action<Exception> ExceptionHandler { get; set; }
Property Value
Remarks
This should be made unmissably visible to developers and testers, ideally with a popup or a modal dialog.
Can be made to rethrow the exception or throw a new exception. If it does, the exception will propagate to the caller. Otherwise, dec will attempt to recover from the error.
If you're using any multithreading, this must be threadsafe.
InfoHandler
Callback for informational messages.
public static Action<string> InfoHandler { get; set; }
Property Value
Remarks
This should be made visible in debug mode.
If you're using any multithreading, this must be threadsafe.
UsingNamespaces
The list of namespaces that dec can access transparently.
public static IEnumerable<string> UsingNamespaces { get; set; }
Property Value
Examples
Config.UsingNamespaces = new string[] { "LegendOfAmethystFuton" };
Remarks
Generally this should consist of your project's primary namespace. If your project lives in multiple namespaces, you may wish to include them all.
Should not be changed while a Parser or Composer object exists.
WarningHandler
Callback for warning messages.
public static Action<string> WarningHandler { get; set; }
Property Value
Remarks
This should be made visible to developers and testers.
If you're using any multithreading, this must be threadsafe.