Click or drag to resize

MessageT1, T2  Conversion (String to MessageT1, T2)

Allows casting a string to a message.

Namespace:  KSPDev.GUIUtils
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
public static implicit operator Message<T1, T2> (
	string tag
)
Request Example View Source

Parameters

tag
Type: SystemString
The tag string to use for getting the localized content.

Return Value

Type: MessageT1, T2
A message instance.
Remarks
It can be used to create a message by simply assigning a localization tag. However, it's highly recommended to create a message via the constructor and provide all the arguments.
Examples
public class Message2Demo : PartModule {
  // The encouraged way of defining a message.
  static readonly Message<string, int> msg1 = new Message<string, int>(
      "#myLocalizationTag",
      defaultTemplate: "The value of <<1>> is <<2>>",
      description: "A string to present in the KSPDevUtils documentation example. It illustrates"
      + " how the class can be used to localize a message.",
      example: "The value of Blah is 123");

  // A simple way when no extra details are provided.
  static readonly Message<string, int> msg2 = "#myLocalizationTag";

  public override void OnAwake() {
    base.OnAwake();

    // This will load the localized string and print it into the log.
    HostedDebugLog.Info(this, msg1.Format("Blah", 123));

    // The next example will only work if there is a localizable string defined. Otherwise, it will
    // print the tag.
    HostedDebugLog.Info(this, msg2.Format("Blah", 123));
  }
}
See Also