Exemplo n.º 1
0
        public static void Load(IBaseApi baseApi)
        {
            var lake = new ChinaLake();

            lake.RegisterSingleton(baseApi);
            lake.RegisterSingleton <IMd5, Md5Impl>();
            lake.RegisterSingleton <IEmbeddedFileManager, EmbeddedFileManagerImpl>();
            lake.RegisterSingleton <IDeviceManager, DeviceSelectorImpl>();
            lake.RegisterSingleton <IOperatingSystemAPI, OSImpl>();
            lake.Register <IStorageManager, StorageManagerImpl>();

            LakeProvider.Lake = lake;
        }
Exemplo n.º 2
0
        public void CreateInstanceTest()
        {
            var   pb    = new ProxyBuilder();
            var   proxy = pb.CreateProxyOf <F**k>();
            ILake lake  = new ChinaLake();

            lake.RegisterSingleton <ILake>(lake);
            proxy.Lakes.Add(lake);
            proxy.CreateInstance(new Dictionary <string, object>()
            {
                { "test", 1 }, { "test2", "c" }
            });
            Assert.IsTrue(proxy.Instance != null);
            Assert.IsTrue(proxy.Instance.Test == 1);
            Assert.IsTrue(proxy.Instance.Test2 == "c");
            Assert.IsTrue(proxy.Instance.Lake == lake);
        }
Exemplo n.º 3
0
        public void InvokeMethodTest()
        {
            var   pb    = new ProxyBuilder();
            var   proxy = pb.CreateProxyOf(typeof(InvokeClass));
            ILake lake  = new ChinaLake();

            lake.RegisterSingleton <ILake>(lake);
            proxy.Lakes.Add(lake);
            proxy.CreateInstance();
            var invokeSuccess = false;
            var callback      = new Action <string, ILake>((a, _lake) =>
            {
                invokeSuccess = a != null && _lake != null;
            });

            proxy.InvokeMethod("F**k", new Dictionary <string, object>()
            {
                { "a", "b" }, { "callback", callback }
            });
            Assert.IsTrue(invokeSuccess);
        }