當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ice.Ice.ArrayUtil類代碼示例

本文整理匯總了TypeScript中ice.Ice.ArrayUtil的典型用法代碼示例。如果您正苦於以下問題:TypeScript Ice.ArrayUtil類的具體用法?TypeScript Ice.ArrayUtil怎麽用?TypeScript Ice.ArrayUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Ice.ArrayUtil類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: allTests

    async allTests()
    {
        async function createTestIntfPrx(adapters:Test.RemoteObjectAdapterPrx[])
        {
            let endpoints:Ice.Endpoint[] = [];
            let obj = null;
            for(const adapter of adapters)
            {
                obj = await adapter.getTestIntf();
                endpoints = endpoints.concat(obj.ice_getEndpoints());
            }
            return Test.TestIntfPrx.uncheckedCast(obj.ice_endpoints(endpoints));
        }

        async function deactivate(communicator:Test.RemoteCommunicatorPrx,
                                  adapters:Test.RemoteObjectAdapterPrx[])
        {
            for(const adapter of adapters)
            {
                await communicator.deactivateObjectAdapter(adapter);
            }
        }

        const out = this.getWriter();
        let communicator = this.communicator();
        const properties = communicator.getProperties().clone();
        out.write("testing stringToProxy... ");
        const ref = "communicator:" + this.getTestEndpoint();
        let com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref));
        test(com !== null);
        out.writeLine("ok");

        out.write("testing binding with single endpoint... ");
        {
            const adapter = await com.createObjectAdapter("Adapter", "default");

            const test1 = await adapter.getTestIntf();
            const test2 = await adapter.getTestIntf();
            test(await test1.ice_getConnection() === await test2.ice_getConnection());

            await test1.ice_ping();
            await test2.ice_ping();

            await com.deactivateObjectAdapter(adapter);

            const test3 = Test.TestIntfPrx.uncheckedCast(test1);
            test(await test3.ice_getConnection() === await test1.ice_getConnection());
            test(await test3.ice_getConnection() === await test2.ice_getConnection());

            try
            {
                await test3.ice_ping();
                test(false);
            }
            catch(ex)
            {
                test(isConnectionFailed(ex), ex);
            }

        }
        out.writeLine("ok");

        await communicator.destroy();
        [communicator] = this.initialize(properties);
        com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref));

        out.write("testing binding with multiple endpoints... ");
        {
            const adapters = await Promise.all(
                [
                    com.createObjectAdapter("Adapter11", "default"),
                    com.createObjectAdapter("Adapter12", "default"),
                    com.createObjectAdapter("Adapter13", "default")
                ]);

            //
            // Ensure that when a connection is opened it's reused for new
            // proxies and that all endpoints are eventually tried.
            //
            let names = ["Adapter11", "Adapter12", "Adapter13"];
            while(names.length > 0)
            {
                const adpts = Ice.ArrayUtil.clone(adapters);
                const test1 = await createTestIntfPrx(adpts);
                Ice.ArrayUtil.shuffle(adpts);
                const test2 = await createTestIntfPrx(adpts);
                Ice.ArrayUtil.shuffle(adpts);
                const test3 = await createTestIntfPrx(adpts);
                await test1.ice_ping();
                test(await test1.ice_getConnection() == await test2.ice_getConnection());
                test(await test2.ice_getConnection() == await test3.ice_getConnection());

                const name = await test1.getAdapterName();
                const index = names.indexOf(name);
                if(index !== -1)
                {
                    names.splice(index, 1);
                }

                const conn = await test1.ice_getConnection();
//.........這裏部分代碼省略.........
開發者ID:zeroc-ice,項目名稱:ice-debian-packaging,代碼行數:101,代碼來源:Client.ts

示例2: run


//.........這裏部分代碼省略.........
        for(const [key, value] of ctx)
        {
            if(!combined.has(key))
            {
                combined.set(key, value);
            }
        }

        test(combined.get("one") == "UN");

        p3 = Test.MyClassPrx.uncheckedCast(p3.ice_context(prxContext));

        ic.getImplicitContext().setContext(null);
        test(Ice.MapUtil.equals(await p3.opContext(), prxContext));

        ic.getImplicitContext().setContext(ctx);
        test(Ice.MapUtil.equals(await p3.opContext(), combined));

        test(ic.getImplicitContext().remove("one") == "ONE");

        await ic.destroy();
    }

    {
        const d = 1278312346.0 / 13.0;
        const ds = [];
        for(let i = 0; i < 5; i++)
        {
            ds[i] = d;
        }

        await prx.opDoubleMarshaling(d, ds);
        await prx.opIdempotent();
        await prx.opNonmutating();
    }

    {

        test(await prx.opByte1(0xFF) == 0xFF);
        test(await prx.opShort1(0x7FFF) == 0x7FFF);
        test(await prx.opInt1(0x7FFFFFFF) == 0x7FFFFFFF);
        test((await prx.opLong1(new Ice.Long(0x7FFFFFFF, 0xFFFFFFFF))).equals(new Ice.Long(0x7FFFFFFF, 0xFFFFFFFF)));
        test(await prx.opFloat1(1.0) == 1.0);
        test(await prx.opDouble1(1.0) == 1.0);
        test(await prx.opString1("opString1") == "opString1");
        test((await prx.opStringS1(null)).length === 0);
        test((await prx.opByteBoolD1(null)).size === 0);
        test((await prx.opStringS2(null)).length === 0);
        test((await prx.opByteBoolD2(null)).size === 0);

        const d = Test.MyDerivedClassPrx.uncheckedCast(prx);
        let s = new Test.MyStruct1();
        s.tesT = "Test.MyStruct1.s";
        s.myClass = null;
        s.myStruct1 = "Test.MyStruct1.myStruct1";
        s = await d.opMyStruct1(s);
        test(s.tesT == "Test.MyStruct1.s");
        test(s.myClass === null);
        test(s.myStruct1 == "Test.MyStruct1.myStruct1");
        let c = new Test.MyClass1();
        c.tesT = "Test.MyClass1.testT";
        c.myClass = null;
        c.myClass1 = "Test.MyClass1.myClass1";
        c = await d.opMyClass1(c);
        test(c.tesT == "Test.MyClass1.testT");
        test(c.myClass === null);
        test(c.myClass1 == "Test.MyClass1.myClass1");
    }

    {
        const p1 = await prx.opMStruct1();
        p1.e = Test.MyEnum.enum3;
        const [p2, p3] = await prx.opMStruct2(p1);
        test(p2.equals(p1) && p3.equals(p1));
    }

    {
        await prx.opMSeq1();
        const p1 = ["test"];
        const [p2, p3] = await prx.opMSeq2(p1);
        test(Ice.ArrayUtil.equals(p2, p1) && Ice.ArrayUtil.equals(p3, p1));
    }

    {
        await prx.opMDict1();
        const p1 = new Map();
        p1.set("test", "test");
        const [p2, p3] = await prx.opMDict2(p1);
        test(Ice.MapUtil.equals(p2, p1) && Ice.MapUtil.equals(p3, p1));
    }

    {
        const ds = [];
        for(let i = 0; i < 5; i++)
        {
            ds[i] = 1278312346.0 / 13.0;
        }
        await prx.opDoubleMarshaling(1278312346.0 / 13.0, ds);
    }
}
開發者ID:zeroc-ice,項目名稱:ice-debian-packaging,代碼行數:101,代碼來源:Twoways.ts


注:本文中的ice.Ice.ArrayUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。