-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueueAgentFactory.cs
37 lines (29 loc) · 1.2 KB
/
QueueAgentFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Collections.Generic;
using NewRelic.Platform.Sdk;
namespace ScalableBytes.NewRelic.AzureStorageQueueSize.Plugin
{
public class QueueAgentFactory : AgentFactory
{
public QueueAgentFactory()
: base("queue-agent-config.json")
{
}
// This will return the deserialized properties from the specified configuration file
// It will be invoked once per JSON object in the configuration file
public override Agent CreateAgentWithConfiguration(IDictionary<string, object> properties)
{
var systemName = (string)properties["systemName"];
var storageAccounts = (List<object>) properties["storageAccounts"];
var typedStorageAccounts = new List<Dictionary<string, string>>();
foreach (var obj in storageAccounts)
{
var dic = (Dictionary<string, object>) obj;
var newDic = new Dictionary<string, string>();
foreach (var acc in dic)
newDic[acc.Key] = (string) acc.Value;
typedStorageAccounts.Add(newDic);
}
return new QueueAgent(systemName, typedStorageAccounts);
}
}
}