Skip to content

Commit

Permalink
change strings to enums
Browse files Browse the repository at this point in the history
  • Loading branch information
pyeremenko committed Feb 20, 2014
1 parent 449cc27 commit 5790a33
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/IronSharp.IronMQ/Alert.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using System;
using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace IronSharp.IronMQ
{
public class Alert
{
public Alert() : this(null, null, null, null)
public Alert() : this(AlertType.Fixed, AlertDirection.Asc, null, null)
{
}

public Alert(string type, string direction, int? trigger, string queue)
public Alert(AlertType type, AlertDirection direction, int? trigger, string queue)
{
Type = type;
Direction = direction;
Expand All @@ -30,11 +31,11 @@ public Alert(string type, string direction, int? trigger, string queue)
[JsonProperty("trigger", DefaultValueHandling = DefaultValueHandling.Ignore)]
public int? Trigger { get; set; }

[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Include)]
public AlertType Type { get; set; }

[JsonProperty("direction", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string Direction { get; set; }
[JsonProperty("direction", DefaultValueHandling = DefaultValueHandling.Include)]
public AlertDirection Direction { get; set; }

[JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string Status { get; set; }
Expand Down
20 changes: 20 additions & 0 deletions src/IronSharp.IronMQ/AlertDirection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace IronSharp.IronMQ
{
[JsonConverter(typeof(StringEnumConverter))]
public enum AlertDirection
{
[EnumMember(Value = "asc")]
Asc,
[EnumMember(Value = "desc")]
Desc
}
}
20 changes: 20 additions & 0 deletions src/IronSharp.IronMQ/AlertType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace IronSharp.IronMQ
{
[JsonConverter(typeof(StringEnumConverter))]
public enum AlertType
{
[EnumMember(Value = "fixed")]
Fixed,
[EnumMember(Value = "progressive")]
Progressive
}
}
3 changes: 3 additions & 0 deletions src/IronSharp.IronMQ/IronSharp.IronMQ.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Runtime.Serialization" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(SolutionDir)/SolutionInfo.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Alert.cs" />
<Compile Include="AlertCollection.cs" />
<Compile Include="AlertType.cs" />
<Compile Include="AlertDirection.cs" />
<Compile Include="Client.cs" />
<Compile Include="IronMqCloudHosts.cs" />
<Compile Include="IronMqRestClient.cs" />
Expand Down

0 comments on commit 5790a33

Please sign in to comment.