diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-08-24 21:39:50 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-08-24 21:39:50 -0400 |
commit | 1bd67baae116b0307b351222b056a0615107eb3c (patch) | |
tree | 00703b77755d4c6098fa22d4f9f08c51e24b5cdc /src/SMAPI/Framework/ModLoading/Rewriters | |
parent | 94b8262692d2452e77d57fa22046dded231cdb0a (diff) | |
download | SMAPI-1bd67baae116b0307b351222b056a0615107eb3c.tar.gz SMAPI-1bd67baae116b0307b351222b056a0615107eb3c.tar.bz2 SMAPI-1bd67baae116b0307b351222b056a0615107eb3c.zip |
support mapping fields to a different type in FieldReplaceRewriter
Diffstat (limited to 'src/SMAPI/Framework/ModLoading/Rewriters')
-rw-r--r-- | src/SMAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs index 8043b13a..9166ab86 100644 --- a/src/SMAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs +++ b/src/SMAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs @@ -26,17 +26,27 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters ** Public methods *********/ /// <summary>Construct an instance.</summary> - /// <param name="type">The type whose field to rewrite.</param> + /// <param name="fromType">The type whose field to rewrite.</param> /// <param name="fromFieldName">The field name to rewrite.</param> + /// <param name="toType">The new type which will have the field.</param> /// <param name="toFieldName">The new field name to reference.</param> - public FieldReplaceRewriter(Type type, string fromFieldName, string toFieldName) - : base(defaultPhrase: $"{type.FullName}.{fromFieldName} field") + public FieldReplaceRewriter(Type fromType, string fromFieldName, Type toType, string toFieldName) + : base(defaultPhrase: $"{fromType.FullName}.{fromFieldName} field") { - this.Type = type; + this.Type = fromType; this.FromFieldName = fromFieldName; - this.ToField = type.GetField(toFieldName); + this.ToField = toType.GetField(toFieldName); if (this.ToField == null) - throw new InvalidOperationException($"The {type.FullName} class doesn't have a {toFieldName} field."); + throw new InvalidOperationException($"The {toType.FullName} class doesn't have a {toFieldName} field."); + } + + /// <summary>Construct an instance.</summary> + /// <param name="type">The type whose field to rewrite.</param> + /// <param name="fromFieldName">The field name to rewrite.</param> + /// <param name="toFieldName">The new field name to reference.</param> + public FieldReplaceRewriter(Type type, string fromFieldName, string toFieldName) + : this(type, fromFieldName, type, toFieldName) + { } /// <summary>Rewrite a CIL instruction reference if needed.</summary> |