-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOscMessageFactory.cs
More file actions
37 lines (28 loc) · 864 Bytes
/
OscMessageFactory.cs
File metadata and controls
37 lines (28 loc) · 864 Bytes
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;
using System.Collections.Generic;
namespace Suhock.Osc;
public sealed class OscMessageFactory: IOscMessageFactory
{
private readonly IOscArgumentFactory _argumentFactory;
public OscMessageFactory() : this(new OscArgumentFactory())
{
}
public OscMessageFactory(IOscArgumentFactory argumentFactory)
{
_argumentFactory = argumentFactory;
}
public OscMessage Create(string address, params object[] args)
{
var argList = new List<IOscArgument>(args.Length);
foreach (var value in args)
{
var arg = _argumentFactory.FromValue(value);
if (arg == null)
{
throw new Exception($"Invalid type: {value.GetType()}");
}
argList.Add(arg);
}
return new OscMessage(address, argList);
}
}