okay, so yes, if an extension implements this by crashing, we'll throw an exception, that makes sense

This commit is contained in:
Mike Griese
2024-12-10 17:43:50 -06:00
parent a27cd54501
commit 5a366b523b
3 changed files with 11 additions and 13 deletions

View File

@@ -148,7 +148,7 @@ public partial class MastodonExtensionActionsProvider : CommandProvider
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "This is sample code")]
public partial class MastodonPostForm : IForm
public partial class MastodonPostForm : Form
{
private readonly MastodonStatus post;
@@ -157,7 +157,7 @@ public partial class MastodonPostForm : IForm
this.post = post;
}
public string DataJson()
public override string DataJson()
{
return $$"""
{
@@ -171,11 +171,9 @@ public partial class MastodonPostForm : IForm
""";
}
public string StateJson() => throw new NotImplementedException();
public override ICommandResult SubmitForm(string payload) => CommandResult.Dismiss();
public ICommandResult SubmitForm(string payload) => CommandResult.Dismiss();
public string TemplateJson()
public override string TemplateJson()
{
var img_block = string.Empty;
if (post.MediaAttachments.Count > 0)

View File

@@ -4,13 +4,13 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
public class Form : IForm
public abstract class Form : IForm
{
public string Data { get; set; } = string.Empty;
public virtual string Data { get; set; } = string.Empty;
public string State { get; set; } = string.Empty;
public virtual string State { get; set; } = string.Empty;
public string Template { get; set; } = string.Empty;
public virtual string Template { get; set; } = string.Empty;
public virtual string DataJson() => Data;
@@ -18,5 +18,5 @@ public class Form : IForm
public virtual string TemplateJson() => Template;
public virtual ICommandResult SubmitForm(string payload) => throw new NotImplementedException();
public abstract ICommandResult SubmitForm(string payload);
}

View File

@@ -4,7 +4,7 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
public partial class FormPage : Page, IFormPage
public abstract partial class FormPage : Page, IFormPage
{
public virtual IForm[] Forms() => throw new NotImplementedException();
public abstract IForm[] Forms();
}