Skip to content

Commit

Permalink
Removing string literals and using BindingType enum
Browse files Browse the repository at this point in the history
  • Loading branch information
mathewc committed Mar 17, 2016
1 parent 60c80e0 commit fe4bb7a
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/WebJobs.Script/Binding/BlobBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
using System.Reflection.Emit;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Host.Bindings.Path;
using Microsoft.Azure.WebJobs.Script.Description;

namespace Microsoft.Azure.WebJobs.Script.Binding
{
public class BlobBinding : FunctionBinding
{
private readonly BindingTemplate _pathBindingTemplate;

public BlobBinding(ScriptHostConfiguration config, string name, string path, FileAccess access, bool isTrigger) : base(config, name, "blob", access, isTrigger)
public BlobBinding(ScriptHostConfiguration config, string name, string path, FileAccess access, bool isTrigger) : base(config, name, BindingType.Blob, access, isTrigger)
{
if (string.IsNullOrEmpty(path))
{
Expand Down
2 changes: 1 addition & 1 deletion src/WebJobs.Script/Binding/EasyTableBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class EasyTableBinding : FunctionBinding
private readonly BindingDirection _bindingDirection;

public EasyTableBinding(ScriptHostConfiguration config, string name, string tableName, string id, FileAccess access, BindingDirection direction) :
base(config, name, "easytable", access, false)
base(config, name, BindingType.EasyTable, access, false)
{
this.TableName = tableName;
this.Id = id;
Expand Down
3 changes: 2 additions & 1 deletion src/WebJobs.Script/Binding/EventHubBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Reflection.Emit;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Host.Bindings.Path;
using Microsoft.Azure.WebJobs.Script.Description;

namespace Microsoft.Azure.WebJobs.Script.Binding
{
Expand All @@ -15,7 +16,7 @@ public class EventHubBinding : FunctionBinding
private readonly BindingTemplate _eventHubNameBindingTemplate;

public EventHubBinding(ScriptHostConfiguration config, string name, string eventHubName, FileAccess access, bool isTrigger) :
base(config, name, "eventhub", access, isTrigger)
base(config, name, BindingType.EventHub, access, isTrigger)
{
if (string.IsNullOrEmpty(eventHubName))
{
Expand Down
4 changes: 2 additions & 2 deletions src/WebJobs.Script/Binding/FunctionBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class FunctionBinding
{
private readonly ScriptHostConfiguration _config;

protected FunctionBinding(ScriptHostConfiguration config, string name, string type, FileAccess access, bool isTrigger)
protected FunctionBinding(ScriptHostConfiguration config, string name, BindingType type, FileAccess access, bool isTrigger)
{
_config = config;
Name = name;
Expand All @@ -28,7 +28,7 @@ protected FunctionBinding(ScriptHostConfiguration config, string name, string ty

public string Name { get; private set; }

public string Type { get; private set; }
public BindingType Type { get; private set; }

public bool IsTrigger { get; private set; }

Expand Down
3 changes: 2 additions & 1 deletion src/WebJobs.Script/Binding/HttpBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Net.Http.Headers;
using System.Reflection.Emit;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Script.Description;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

Expand All @@ -18,7 +19,7 @@ public class HttpBinding : FunctionBinding, IResultProcessingBinding
{
internal const string HttpResponsePropertyKey = "MS_AzureFunctionsHttpResponse";

public HttpBinding(ScriptHostConfiguration config, string name, FileAccess access, bool isTrigger) : base(config, name, "http", access, isTrigger)
public HttpBinding(ScriptHostConfiguration config, string name, FileAccess access, bool isTrigger) : base(config, name, BindingType.Http, access, isTrigger)
{
}

Expand Down
3 changes: 2 additions & 1 deletion src/WebJobs.Script/Binding/QueueBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
using System.Reflection.Emit;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Host.Bindings.Path;
using Microsoft.Azure.WebJobs.Script.Description;

namespace Microsoft.Azure.WebJobs.Script.Binding
{
public class QueueBinding : FunctionBinding
{
private readonly BindingTemplate _queueNameBindingTemplate;

public QueueBinding(ScriptHostConfiguration config, string name, string queueName, FileAccess access, bool isTrigger) : base(config, name, "queue", access, isTrigger)
public QueueBinding(ScriptHostConfiguration config, string name, string queueName, FileAccess access, bool isTrigger) : base(config, name, BindingType.Queue, access, isTrigger)
{
if (string.IsNullOrEmpty(queueName))
{
Expand Down
3 changes: 2 additions & 1 deletion src/WebJobs.Script/Binding/ServiceBusBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
using System.Reflection.Emit;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Host.Bindings.Path;
using Microsoft.Azure.WebJobs.Script.Description;

namespace Microsoft.Azure.WebJobs.Script.Binding
{
public class ServiceBusBinding : FunctionBinding
{
private readonly BindingTemplate _queueOrTopicNameBindingTemplate;

public ServiceBusBinding(ScriptHostConfiguration config, string name, string queueOrTopicName, FileAccess access, bool isTrigger) : base(config, name, "serviceBus", access, isTrigger)
public ServiceBusBinding(ScriptHostConfiguration config, string name, string queueOrTopicName, FileAccess access, bool isTrigger) : base(config, name, BindingType.ServiceBus, access, isTrigger)
{
if (string.IsNullOrEmpty(queueOrTopicName))
{
Expand Down
4 changes: 3 additions & 1 deletion src/WebJobs.Script/Binding/TableBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Reflection.Emit;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Host.Bindings.Path;
using Microsoft.Azure.WebJobs.Script.Description;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Newtonsoft.Json;
Expand All @@ -21,7 +22,8 @@ public class TableBinding : FunctionBinding
private readonly BindingTemplate _rowKeyBindingTemplate;
private readonly TableQuery _tableQuery;

public TableBinding(ScriptHostConfiguration config, string name, string tableName, string partitionKey, string rowKey, FileAccess access, TableQuery tableQuery = null) : base(config, name, "queue", access, false)
public TableBinding(ScriptHostConfiguration config, string name, string tableName, string partitionKey, string rowKey, FileAccess access, TableQuery tableQuery = null)
: base(config, name, BindingType.Table, access, false)
{
if (string.IsNullOrEmpty(tableName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private ImmutableArray<Diagnostic> ValidateFunctionBindingArguments(CSharpFuncti

foreach (var binding in bindings)
{
if (binding.Type == "http")
if (binding.Type == BindingType.Http)
{
continue;
}
Expand Down

0 comments on commit fe4bb7a

Please sign in to comment.