示例#1
0
 /// <summary>
 /// Converts an object to a string.
 /// </summary>
 /// <remarks>
 /// `input` will be one of the types provided in HandledTypes(); it will not be null. Whatever you return should be convertable back to an object by an overridden FromString().
 ///
 /// In case of error, call Def.Dbg.Err with some appropriately useful message and return null.
 /// </remarks>
 public virtual string ToString(object input)
 {
     Dbg.Err($"Failed to generate a string when attempting to record {input.GetType()}");
     return(null);
 }
示例#2
0
 /// <summary>
 /// Converts a string to a suitable object type.
 /// </summary>
 /// <remarks>
 /// `type` is set to the expected return type; you can return null, or anything that can be implicitly converted to that type.
 ///
 /// In case of error, call Def.Dbg.Err with some appropriately useful message and return null. Message should be formatted as $"{inputName}:{lineNumber}: Something went wrong".
 ///
 /// Note: In the case of empty input (i.e. &lt;member&gt;&lt;/member&gt; or &lt;member /&gt;) this function will be called.
 /// </remarks>
 public virtual object FromString(string input, Type type, string inputName, int lineNumber)
 {
     Dbg.Err($"{inputName}:{lineNumber}: Failed to parse string when attempting to parse {type}");
     return(null);
 }