Class GeneratedExtension
A class providing an extension for Config to make it easy to use generated config stores.
Inherited Members
Namespace: IPA.Config.Stores
Assembly: IPA.Loader.dll
Syntax
public static class GeneratedExtension
Fields
| Improve this Doc View SourceAssemblyVisibilityTarget
The name of the assembly that internals must be visible to to allow internal protection.
Declaration
public const string AssemblyVisibilityTarget = "IPA.Config.Generated"
Field Value
Type | Description |
---|---|
String |
Methods
| Improve this Doc View SourceGenerated<T>(Config, Boolean)
Creates a generated IConfigStore of type T
, registers it to
the Config object, and returns it. This also forces a synchronous config load via
LoadSync() if loadSync
is true.
Declaration
public static T Generated<T>(this Config cfg, bool loadSync = true)
where T : class
Parameters
Type | Name | Description |
---|---|---|
Config | cfg | the Config to register to |
Boolean | loadSync | whether to synchronously load the content, or trigger an async load |
Returns
Type | Description |
---|---|
T | a generated instance of |
Type Parameters
Name | Description |
---|---|
T | the type to wrap |
Remarks
T
must be a public non-sealed class.
It can also be internal, but in that case, then your assembly must have the following attribute
to allow the generated code to reference it.
[assembly: InternalsVisibleTo(IPA.Config.Stores.GeneratedExtension.AssemblyVisibilityTarget)]
Only fields and properties that are public or protected will be considered, and only properties where both the getter and setter are public or protected are considered. Any fields or properties with an IgnoreAttribute applied to them are also ignored. Having properties be virtual is not strictly necessary, however it allows the generated type to keep track of changes and lock around them so that the config will auto-save.
All of the attributes in the IPA.Config.Stores.Attributes namespace are handled as described by them.
If the T
declares a public or protected, virtual
method Changed()
, then that method may be called to artificially signal to the runtime that the content of the object
has changed. That method will also be called after the write locks are released when a property is set anywhere in the owning
tree. This will only be called on the outermost generated object of the config structure, even if the change being signaled
is somewhere deep into the tree. TODO: is this a good idea?
Similarly, T
can declare a public or protected, virtual
method OnReload()
, which will be called on the filesystem reader thread after the object has been repopulated with new data
values. It will be called after the write lock for this object is released. This will only be called on the outermost generated
object of the config structure.
TODO: describe details of generated stores