SiftOsc.SiftOscCube.generateFromYaml C# (CSharp) Method

generateFromYaml() public method

public generateFromYaml ( YamlMappingNode cubeEventsNode ) : void
cubeEventsNode YamlMappingNode
return void
        public void generateFromYaml(YamlMappingNode cubeEventsNode)
        {
            foreach (var cubeEvent in cubeEventsNode.Children) {
            String cubeEventName = (((YamlScalarNode)cubeEvent.Key).Value);

            YamlMappingNode eventEndpoints = (YamlMappingNode)cubeEvent.Value;
            List<SiftOscCubeEvent> cubeEvents = new List<SiftOscCubeEvent>();

            foreach (var eventEndpoint in eventEndpoints.Children) {
              SiftOscCubeEvent siftOscCubeEvent = new SiftOscCubeEvent(cube, this.client, null, null);
              siftOscCubeEvent.generateFromYaml(eventEndpoint);
              cubeEvents.Add(siftOscCubeEvent);
            }

            this.siftOscCubeEvents.Add(cubeEventName, cubeEvents);
              }
        }

Usage Example

Beispiel #1
0
        static void Main(string[] args)
        {
            SiftOsc app = new SiftOsc();
              OscClient client = new OscClient(IPAddress.Loopback, 7001);
              app.setClient(client);
              app.siftOscCubes = new Dictionary<int, SiftOscCube>();
              app.siftOscCallbacks = new Dictionary<SiftOscCube, String>();

              StreamReader input = new StreamReader("config.yml");
              StringReader content = new StringReader(input.ReadToEnd());

              var yaml = new YamlStream();
              yaml.Load(content);
              YamlMappingNode mapping = (YamlMappingNode)yaml.Documents[0].RootNode;

              foreach (var cubeID in mapping.Children) {
            String cubeIDName = (((YamlScalarNode)cubeID.Key).Value);
            SiftOscCube cube = new SiftOscCube(null, client, null);
            app.addCube(Int32.Parse(cubeIDName), cube);
            cube.generateFromYaml((YamlMappingNode)cubeID.Value);
              }

              app.Run();
        }