Exemple #1
0
        public void TestLoadAndInterfaceWithConstructor()
        {
            CrossDomainCompiler.LoadScript(@"test\SimpleInterface.json", @"test");
            var cp = new object[] {};

            CrossDomainCompiler.Call(@"test", typeof(SimpleInterface), "ImplWithConstructor", "CallMe", ref cp);
        }
Exemple #2
0
        public void TestLoadAndCallMethodWithArgumentImpl()
        {
            CrossDomainCompiler.LoadScript(@"test\SimpleInterface.json", @"test");
            var cp = new object[] {};
            var mp = new object[] { "Hellow world!" };

            CrossDomainCompiler.Call(@"test", typeof(MethodWithArgument), "MethodWithArgumentImpl", "CallMe", ref cp, ref mp);
        }
Exemple #3
0
 public void TestLoadWatcher()
 {
     CrossDomainCompiler.LoadScript(@"test\SimpleInterface.json", @"test");
     //watcher
     while (true)
     {
         Thread.Sleep(1000);
     }
 }
Exemple #4
0
        public void TestLoadAndCallMethodWithArgumentModifyImpl()
        {
            CrossDomainCompiler.LoadScript(@"test\SimpleInterface.json", @"test");
            var cp = new object[] {};
            var mp = new object[] { "Hellow world!" };

            CrossDomainCompiler.Call(@"test", typeof(MethodWithArgumentChanged), "MethodWithArgumentChangedImpl", "CallMe", ref cp, ref mp);
            StringAssert.AreEqualIgnoringCase("Hello Unit.", (string)mp[0]);
        }
Exemple #5
0
        public void TestLoadAndCallPerf()
        {
            CrossDomainCompiler.LoadScript(@"test\SimpleInterface.json", @"test");
            var       start = DateTime.Now;
            const int upper = 100;

            for (var i = 0; i < upper; i++)
            {
                CrossDomainCompiler.Call(@"test", typeof(SimpleInterface), "ImplWithConstructor", "CallMe");
            }
            var end      = DateTime.Now;
            var tpercall = ((end.Ticks - start.Ticks) / upper / 10000);

            Assert.Less(tpercall, 20);
        }
Exemple #6
0
        public void Initialize()
        {
            //var catalog = new AssemblyCatalog(typeof(CxxAdapterManager).Assembly);
            var catalog             = new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory, "*.*");
            CompositionContainer cc = new CompositionContainer(catalog);

            cc.ComposeParts(this);

            _adapterMap = new Dictionary <uint, ISensorAdapter>();
            foreach (Lazy <ISensorAdapter, ISensorProtocol> sa in _adapters)
            {
                _adapterMap[sa.Metadata.Protocol] = sa.Value;
            }
            ReLoad();
            try
            {
                CrossDomainCompiler.LoadScript(string.Format("{0}\\{1}", _adapterPath, AdapterReferences), _adapterPath);
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("脚本编译错误{0}", ex.Message);
            }
        }
Exemple #7
0
 public void TestLoadAndCall()
 {
     CrossDomainCompiler.LoadScript(@"test\SimpleInterface.json", @"test");
     CrossDomainCompiler.Call(@"test", typeof(SimpleInterface), "ImplWithConstructor", "CallMe");
 }
Exemple #8
0
 public void TestLoad()
 {
     CrossDomainCompiler.LoadScript(@"test\SimpleInterface.json", @"test");
     //reload
     CrossDomainCompiler.LoadScript(@"test\SimpleInterface.json", @"test");
 }
Exemple #9
0
 public void TestLoadDependConfigNotFound()
 {
     CrossDomainCompiler.LoadScript(@"test\SimpleInterface1.json", @"test\out");
 }
Exemple #10
0
 public void TestLoadDirectoryEmpty()
 {
     CrossDomainCompiler.LoadScript(@"test\SimpleInterface.json", @"test\out");
 }
Exemple #11
0
 public void TestLoadDirectoryNotFound()
 {
     CrossDomainCompiler.LoadScript(@"test\SimpleInterface.json", @"test\notexist");
 }
Exemple #12
0
 public void TestLoadCompileError()
 {
     CrossDomainCompiler.LoadScript(@"test\SimpleInterface.json", @"test\error");
 }