summaryrefslogtreecommitdiffstats
path: root/embedding/csharp/uSCXMLEmbedding/Program.cs
blob: 0c76cb46a1c3377e0a695eed55a418d8bcb26152 (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace embedding
{
    using org.uscxml;

    class Program
    {
        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
        private static extern void SetDllDirectory(string lpPathName);

        static bool testLifecycle() {
            // try to instantiate an interpreter with a parse error

            try
            {
                Interpreter interpreter = Interpreter.fromXML("<invalid");
                Debug.Assert(false);
            }
            catch (InterpreterException e) {
                Console.Write(e.Message);
            }

            // try to instantiate an interpreter with invalid XML (no scxml element)

            try
            {
                Interpreter interpreter = Interpreter.fromXML("<invalid />");
                Debug.Assert(interpreter.getState() == InterpreterState.USCXML_INSTANTIATED);
                InterpreterState state = interpreter.step();

                Debug.Assert(false);
            }
            catch (InterpreterException e)
            {
                Console.Write(e.Message);
            }

            return true;
        }

        static void Main(string[] args)
        {

            /*

             * Make sure this path contains the uscxmlNativeCSharp.dll!

             */
            if (System.Environment.Is64BitProcess)
            {
                SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\uscxml64\\lib\\csharp");
            }
            else
            {
                SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\uscxml\\lib\\csharp");
            }

            testLifecycle();
            Console.ReadKey();
        }
    }
}