-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed SetChannelProperty not serializing ValueLookup properly (#76)
- Loading branch information
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
PrtgAPI/Request/Serialization/ValueConverters/ValueLookupConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
|
||
namespace PrtgAPI.Request.Serialization.ValueConverters | ||
{ | ||
class ValueLookupConverter : IValueConverter | ||
{ | ||
internal static ValueLookupConverter Instance = new ValueLookupConverter(); | ||
|
||
public object Serialize(object value) | ||
{ | ||
var none = "|None"; | ||
|
||
if (value != null) | ||
{ | ||
if (value.ToString().Equals("None", StringComparison.OrdinalIgnoreCase)) | ||
return none; | ||
else | ||
return $"{value}|{value}"; | ||
} | ||
else | ||
return none; | ||
} | ||
|
||
public object Deserialize(object value) => value; | ||
} | ||
} |