blob: 866c1483bd8fdca149dcd1f4ad01cfa7a679810e (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using org.uscxml;
using System.Xml;
using System.Xml.XPath;
using System.IO;
namespace embedding
{
class CustomIOProc : IOProcessor
{
public override IOProcessor create(Interpreter interpreter)
{
CustomIOProc ioProc = new CustomIOProc();
ioProc.swigCMemOwn = false;
return ioProc;
}
public override Data getDataModelVariables()
{
Data data = new Data();
return data;
}
public override StringList getNames()
{
StringList names = new StringList();
names.add("custom");
return names;
}
public override void send(SendRequest req)
{
Console.WriteLine(req);
// send in s1.onentry
if ("This is some content!" == req.getContent())
{
returnEvent(new Event("received1"));
return;
}
// send in s2.onentry
if (req.getParams().ContainsKey("foo")
&& "bar" == (req.getParams()["foo"][0].getAtom()))
{
returnEvent(new Event("received2"));
return;
}
// send in s3
if (req.getXML().Length > 0)
{
XmlReaderSettings set = new XmlReaderSettings();
set.ConformanceLevel = ConformanceLevel.Fragment;
XPathDocument doc = new XPathDocument(XmlReader.Create(new StringReader(req.getXML()), set));
XPathNavigator nav = doc.CreateNavigator();
Console.WriteLine("Root element :" + nav.SelectSingleNode("/").Value);
returnEvent(new Event("received3"));
return;
}
}
}
}
|