Reputation: 647
I have a FormDialog that has LUIS entities bound to the state.
public abstract class AbstractFormDialog
{
[Optional]
public string Entity1;
[Optional]
public string Entity2;
[Optional]
public string Entity3;
[Optional]
public string Entity4;
[Optional]
public string Entity5;
}
In a subclass of AbstractFormDialog, I want to be able to say that some of these entities are required, so that "no preference" is not an option. Something like
public abstract class FormDialog1 : AbstractFormDialog
{
[Required]
public string Entity1;
[Required]
public string Entity2;
}
Does anyone know if this is possible? Of course I could make all attributes required in the base class, and then in every class which extends it, list which entities are actually optional. This design is bad though, because if a new Entity were to be added every subclass would need to be updated.
Upvotes: 1
Views: 408
Reputation: 108
You can also control this by utilizing the Field APIs at runtime when you build your form, i.e. new FormBuilder() .Field(new FieldReflector(nameof(FormDialog1.Entity1)) .SetOptional(false)) .Build(); This would make the Entity1 field for this instance "Required".
Upvotes: 1