当前位置: 首页>>代码示例>>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;未经允许,请勿转载。