Пример #1
0
 /// <param name="cfgPath">
 /// A path to the fields's value in the config. Components must be separated by symbol <c>/</c>.
 /// The path is relative, the absolute path is determined when doing actual (de)serialization.
 /// The path is case-insensitive.
 /// </param>
 protected BasePersistentFieldAttribute(string cfgPath)
 {
     this.path = ConfigAccessor.StrToPath(cfgPath);
 }
Пример #2
0
 /// <summary>
 /// Reads a value of an arbitrary type <typeparamref name="T"/> from the config node.
 /// </summary>
 /// <param name="node">The node to read data from.</param>
 /// <param name="path">
 /// The path to the node. The path components should be separated by '/' symbol.
 /// </param>
 /// <param name="typeProto">
 /// A proto that can parse values of type <typeparamref name="T"/>. If not set, then
 /// <see cref="StandardOrdinaryTypesProto"/> is used.
 /// </param>
 /// <returns>The parsed value or <c>null</c> if not found.</returns>
 /// <typeparam name="T">
 /// The value type to write. The <paramref name="typeProto"/> instance must be able to handle it.
 /// </typeparam>
 /// <exception cref="ArgumentException">If type cannot be handled by the proto.</exception>
 /// <seealso cref="SetValueByPath&lt;T&gt;(ConfigNode, string, T, KSPDev.ConfigUtils.AbstractOrdinaryValueTypeProto)"/>
 public static T?GetValueByPath <T>(
     ConfigNode node, string path, AbstractOrdinaryValueTypeProto typeProto = null)
     where T : struct
 {
     return(GetValueByPath <T>(node, ConfigAccessor.StrToPath(path), typeProto));
 }