Skip to content

Commit

Permalink
Added new constructor overloads for various classes
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed Mar 15, 2021
1 parent a8298f5 commit 55725c5
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 15 deletions.
8 changes: 7 additions & 1 deletion src/Skybrud.Forms/Models/Fields/EmailField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
/// </summary>
public class EmailField : InputField {

public EmailField() : base("email") { }
protected const string FieldType = "email";

public EmailField() : base(FieldType) { }

public EmailField(string name) : base(FieldType, name) { }

public EmailField(string name, string value) : base(FieldType, name, value) { }

}

Expand Down
14 changes: 4 additions & 10 deletions src/Skybrud.Forms/Models/Fields/FieldBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class FieldBase {
#region Properties

[JsonProperty("type", Order = -99, NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; protected set; }
public string Type { get; }

[JsonProperty("name", Order = -98, NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; set; }
Expand All @@ -28,7 +28,9 @@ public class FieldBase {

#region Constructors

public FieldBase() { }
public FieldBase(string type) {
Type = type;
}

public FieldBase(string type, string name) {
Type = type;
Expand All @@ -43,14 +45,6 @@ public FieldBase(string type, string name, object value) {

#endregion

#region Static methods

public static FieldBase Hidden(string name, object value) {
return new FieldBase("hidden", name, value);
}

#endregion

}

}
4 changes: 4 additions & 0 deletions src/Skybrud.Forms/Models/Fields/InputField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public abstract class InputField : FieldBase {

protected InputField(string type) : base(type, null, null) { }

protected InputField(string type, string name) : base(type, name) { }

protected InputField(string type, string name, string value) : base(type, name, value) { }

#endregion

}
Expand Down
8 changes: 7 additions & 1 deletion src/Skybrud.Forms/Models/Fields/NumberField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace Skybrud.Forms.Models.Fields {
/// </summary>
public class NumberField : InputField {

protected const string FieldType = "number";

#region Properties

[JsonProperty("min", NullValueHandling = NullValueHandling.Ignore)]
Expand All @@ -19,7 +21,11 @@ public class NumberField : InputField {

#region Constructors

public NumberField() : base("number") { }
public NumberField() : base(FieldType) { }

public NumberField(string name) : base(FieldType, name) { }

public NumberField(string name, string value) : base(FieldType, name, value) { }

#endregion

Expand Down
8 changes: 7 additions & 1 deletion src/Skybrud.Forms/Models/Fields/TelField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
/// </summary>
public class TelField : InputField {

protected const string FieldType = "tel";

#region Constructors

public TelField() : base("tel") { }
public TelField() : base(FieldType) { }

public TelField(string name) : base(FieldType, name) { }

public TelField(string name, string value) : base(FieldType, name, value) { }

#endregion

Expand Down
8 changes: 7 additions & 1 deletion src/Skybrud.Forms/Models/Fields/TextArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace Skybrud.Forms.Models.Fields {
/// </see>
public class TextArea : InputField {

protected const string FieldType = "textarea";

#region Properties

/// <summary>
Expand All @@ -27,7 +29,11 @@ public class TextArea : InputField {
/// <summary>
/// Initialize a new textarea field.
/// </summary>
public TextArea() : base("textarea") { }
public TextArea() : base(FieldType) { }

public TextArea(string name) : base(FieldType, name) { }

public TextArea(string name, string value) : base(FieldType, name, value) { }

#endregion

Expand Down
8 changes: 7 additions & 1 deletion src/Skybrud.Forms/Models/Fields/TextField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
/// </summary>
public class TextField : InputField {

protected const string FieldType = "text";

#region Constructors

public TextField() : base("text") { }
public TextField() : base(FieldType) { }

public TextField(string name) : base(FieldType, name) { }

public TextField(string name, string value) : base(FieldType, name, value) { }

#endregion

Expand Down

0 comments on commit 55725c5

Please sign in to comment.