summaryrefslogtreecommitdiff
path: root/cs/test/Ice/plugin/PluginFactory.cs
blob: 6a10d0a7ed5b4feaa91e3f3ff1ef72f00331703f (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
// **********************************************************************
//
// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

using System;

public class PluginFactory : Ice.PluginFactory
{
    public Ice.Plugin create(Ice.Communicator communicator, string name, string[] args)
    {
        return new Plugin(communicator, args);
    }

    internal class Plugin : Ice.Plugin
    {
        public Plugin(Ice.Communicator communicator, string[] args)
        {
            _args = args;
        }

        public void initialize()
        {
            _initialized = true;
            test(_args.Length == 3);
            test(_args[0] == "C:\\Program Files\\");
            test(_args[1] == "--DatabasePath");
            test(_args[2] == "C:\\Program Files\\Application\\db");
        }

        public void destroy()
        {
            _destroyed = true;
        }

        ~Plugin()
        {
            if(!_initialized)
            {
                Console.WriteLine("Plugin not initialized");
            }
            if(!_destroyed)
            {
                Console.WriteLine("Plugin not destroyed");
            }
        }

        private static void test(bool b)
        {
            if(!b)
            {
                throw new System.Exception();
            }
        }

        private bool _initialized = false;
        private bool _destroyed = false;
        private string[] _args;
    }
}