Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Null checks for field types #692

Merged
merged 2 commits into from
Jun 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/Piranha/Extend/Fields/MediaFieldBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public virtual bool Equals(T obj)
{
return field1.Equals(field2);
}
else if ((object)field1 == null && (object)field2 == null)
{
return true;
}
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions core/Piranha/Extend/Fields/PageField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ public virtual bool Equals(PageField obj)
{
return field1.Equals(field2);
}
else if ((object)field1 == null && (object)field2 == null)
{
return true;
}
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions core/Piranha/Extend/Fields/PostField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ public virtual bool Equals(PostField obj)
{
return field1.Equals(field2);
}
else if ((object)field1 == null && (object)field2 == null)
{
return true;
}
return false;
}

Expand Down
16 changes: 12 additions & 4 deletions core/Piranha/Extend/Fields/SelectField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ public class SelectField<T> : SelectFieldBase, IEquatable<SelectField<T>> where
/// <summary>
/// Gets the current enum type.
/// </summary>
public override Type EnumType {
public override Type EnumType
{
get { return typeof(T); }
}

/// <summary>
/// Gets/sets the selected value as a string.
/// </summary>
public override string EnumValue {
public override string EnumValue
{
get { return Value.ToString(); }
set { Value = (T)Enum.Parse(typeof(T), value); }
}
Expand All @@ -59,8 +61,10 @@ public override string EnumValue {
/// Gets the available items to choose from. Primarily used
/// from the manager interface.
/// </summary>
public override List<SelectFieldItem> Items {
get {
public override List<SelectFieldItem> Items
{
get
{
InitMetaData();

return _items;
Expand Down Expand Up @@ -133,6 +137,10 @@ public virtual bool Equals(SelectField<T> obj)
{
return field1.Equals(field2);
}
else if ((object)field1 == null && (object)field2 == null)
{
return true;
}
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions core/Piranha/Extend/Fields/SimpleField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public virtual bool Equals(SimpleField<T> obj)
{
return field1.Equals(field2);
}
else if ((object)field1 == null && (object)field2 == null)
{
return true;
}
return false;
}

Expand Down