Exemplo n.º 1
0
        /*
         * public THashSet<int> testSet(THashSet<int> thing)
         * {
         *  Console.WriteLine("testSet:" + thing.ToString());
         *
         *  return thing;
         * }
         */

        public void testStruct()
        {
            GenericTree input1 = new GenericTree();

            input1.setName("thing");
            input1.setParamType(TypeEnum.SYNTHETIC_TYPE);
            input1.setThrfitType("STRUCT");
            input1.setType("Xtruct");

            GenericTree prop1 = new GenericTree();

            prop1.setName("String_thing");
            prop1.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop1.setThrfitType("STRING");

            GenericTree prop2 = new GenericTree();

            prop2.setName("Byte_thing");
            prop2.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop2.setThrfitType("SBYTE");

            GenericTree prop3 = new GenericTree();

            prop3.setName("I32_thing");
            prop3.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop3.setThrfitType("I32");

            GenericTree prop4 = new GenericTree();

            prop4.setName("I64_thing");
            prop4.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop4.setThrfitType("I64");

            Dictionary <string, GenericTree> children = new Dictionary <string, GenericTree>();

            children.Add("String_thing", prop1);
            children.Add("Byte_thing", prop2);
            children.Add("I32_thing", prop3);
            children.Add("I64_thing", prop4);

            input1.setChildren(children);

            List <GenericTree> inputGenericTrees = new List <GenericTree>
            {
                input1
            };

            GenericTree input2 = new GenericTree();

            input2.setName("thing");
            input2.setParamType(TypeEnum.SYNTHETIC_TYPE);
            input2.setThrfitType("STRUCT");
            input2.setType("Xtruct");

            GenericTree prop11 = new GenericTree();

            prop11.setName("String_thing");
            prop11.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop11.setThrfitType("STRING");
            prop11.setParent(input2);


            GenericTree prop12 = new GenericTree();

            prop12.setName("Byte_thing");
            prop12.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop12.setThrfitType("SBYTE");

            GenericTree prop13 = new GenericTree();

            prop13.setName("I32_thing");
            prop13.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop13.setThrfitType("I32");

            GenericTree prop14 = new GenericTree();

            prop14.setName("I64_thing");
            prop14.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop14.setThrfitType("I64");

            Dictionary <string, GenericTree> children2 = new Dictionary <string, GenericTree>();

            children2.Add("String_thing", prop11);
            children2.Add("Byte_thing", prop12);
            children2.Add("I32_thing", prop13);
            children2.Add("I64_thing", prop14);

            input2.setChildren(children2);


            // 参数值
            List <Object> inputVals = new List <object>();



            Dictionary <string, object> row = new Dictionary <string, object>();

            row.Add("String_thing", "stringValue3");
            row.Add("Byte_thing", Convert.ToSByte(127));
            row.Add("I32_thing", 99999);
            row.Add("I64_thing", 9999900001111);

            inputVals.Add(row);

            //出参


            string method = SERVICE_NAME + "testStruct";

            GenericNode genericNode = new GenericNode();

            genericNode.setInputs(inputGenericTrees);
            genericNode.setMethodName(method);
            genericNode.setValues(inputVals);
            genericNode.setOutput(input2);

            object obj = genericAnalyser.syncProcess(protocol, genericNode);

            Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
        }
Exemplo n.º 2
0
        public void testMapMap(int hello)
        {
            GenericTree input1 = new GenericTree();

            input1.setName("thing");
            input1.setParamType(TypeEnum.COLLECTION_TYPE);
            input1.setThrfitType("MAP");

            GenericTree innerKey = new GenericTree();

            innerKey.setName("thing1");
            innerKey.setParamType(TypeEnum.PRIMITIVE_TYPE);
            innerKey.setThrfitType("I32");

            GenericTree innerValue = new GenericTree();

            innerValue.setName("thing2");
            innerValue.setParamType(TypeEnum.COLLECTION_TYPE);
            innerValue.setThrfitType("MAP");

            Dictionary <string, GenericTree> valueChildren = new Dictionary <string, GenericTree>();

            valueChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_KEY, innerKey);
            valueChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_VALUE, innerKey);

            innerValue.setChildren(valueChildren);

            Dictionary <string, GenericTree> children = new Dictionary <string, GenericTree>();

            children.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_KEY, innerKey);
            children.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_VALUE, innerValue);

            input1.setChildren(children);

            List <GenericTree> inputGenericTrees = new List <GenericTree>
            {
                innerKey
            };

            // 参数值
            List <Object> inputVals = new List <object>();

            inputVals.Add(hello);

            //出参
            GenericTree output = new GenericTree();

            output.setParamType(TypeEnum.COLLECTION_TYPE);
            output.setThrfitType("MAP");
            output.setName("returnModel");

            GenericTree outKey = new GenericTree();

            outKey.setName("thing");
            outKey.setParamType(TypeEnum.PRIMITIVE_TYPE);
            outKey.setThrfitType("I32");

            GenericTree outValue = new GenericTree();

            outValue.setName("thing");
            outValue.setParamType(TypeEnum.COLLECTION_TYPE);
            outValue.setThrfitType("MAP");

            Dictionary <string, GenericTree> outValueChildren = new Dictionary <string, GenericTree>();

            outValueChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_KEY, outKey);
            outValueChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_VALUE, outKey);

            outValue.setChildren(outValueChildren);

            Dictionary <string, GenericTree> outputChildren = new Dictionary <string, GenericTree>();

            outputChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_KEY, outKey);
            outputChildren.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_VALUE, outValue);

            output.setChildren(outputChildren);

            string method = SERVICE_NAME + "testMapMap";

            GenericNode genericNode = new GenericNode();

            genericNode.setInputs(inputGenericTrees);
            genericNode.setMethodName(method);
            genericNode.setValues(inputVals);
            genericNode.setOutput(output);

            object obj = genericAnalyser.syncProcess(protocol, genericNode);

            Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
        }
Exemplo n.º 3
0
        public void testMulti(sbyte arg0, int arg1, long arg2, Dictionary <short, string> arg3, Numberz arg4, long arg5)
        {
            // 返回 Xtruct

            GenericTree _arg0 = new GenericTree();

            _arg0.setName("arg0");
            _arg0.setParamType(TypeEnum.PRIMITIVE_TYPE);
            _arg0.setThrfitType("SBYTE");

            GenericTree _arg1 = new GenericTree();

            _arg1.setName("_arg1");
            _arg1.setParamType(TypeEnum.PRIMITIVE_TYPE);
            _arg1.setThrfitType("I32");

            GenericTree _arg2 = new GenericTree();

            _arg2.setName("_arg2");
            _arg2.setParamType(TypeEnum.PRIMITIVE_TYPE);
            _arg2.setThrfitType("I64");

            GenericTree _arg3 = new GenericTree();

            _arg3.setName("_arg3");
            _arg3.setParamType(TypeEnum.COLLECTION_TYPE);
            _arg3.setThrfitType("MAP");


            GenericTree innerKey = new GenericTree();

            innerKey.setName("innerKey");
            innerKey.setParamType(TypeEnum.PRIMITIVE_TYPE);
            innerKey.setThrfitType("I16");

            GenericTree innerValue = new GenericTree();

            innerValue.setName("innerValue");
            innerValue.setParamType(TypeEnum.PRIMITIVE_TYPE);
            innerValue.setThrfitType("STRING");

            Dictionary <string, GenericTree> children = new Dictionary <string, GenericTree>();

            children.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_KEY, innerKey);
            children.Add(TGenericClient.PARAMINFO_COLLECTION_MAP_VALUE, innerValue);

            _arg3.setChildren(children);



            GenericTree _arg4 = new GenericTree();

            _arg4.setName("_arg4");
            _arg4.setParamType(TypeEnum.PRIMITIVE_TYPE);
            _arg4.setThrfitType("I32");

            GenericTree _arg5 = new GenericTree();

            _arg5.setName("_arg5");
            _arg5.setParamType(TypeEnum.PRIMITIVE_TYPE);
            _arg5.setThrfitType("I64");

            List <GenericTree> inputGenericTrees = new List <GenericTree>
            {
                _arg0, _arg1, _arg2, _arg3, _arg4, _arg5
            };

            GenericTree input2 = new GenericTree();

            input2.setName("thing");
            input2.setParamType(TypeEnum.SYNTHETIC_TYPE);
            input2.setThrfitType("STRUCT");
            input2.setType("Xtruct");

            GenericTree prop11 = new GenericTree();

            prop11.setName("String_thing");
            prop11.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop11.setThrfitType("STRING");
            prop11.setParent(input2);


            GenericTree prop12 = new GenericTree();

            prop12.setName("Byte_thing");
            prop12.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop12.setThrfitType("SBYTE");
            prop12.setParent(input2);

            GenericTree prop13 = new GenericTree();

            prop13.setName("I32_thing");
            prop13.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop13.setThrfitType("I32");
            prop13.setParent(input2);

            GenericTree prop14 = new GenericTree();

            prop14.setName("I64_thing");
            prop14.setParamType(TypeEnum.PRIMITIVE_TYPE);
            prop14.setThrfitType("I64");
            prop14.setParent(input2);


            // 参数值
            List <Object> inputVals = new List <object>();


            inputVals.Add(arg0);
            inputVals.Add(arg1);
            inputVals.Add(arg2);
            inputVals.Add(arg3);
            inputVals.Add(arg4);
            inputVals.Add(arg5);

            //出参


            string method = SERVICE_NAME + "testMulti";

            GenericNode genericNode = new GenericNode();

            genericNode.setInputs(inputGenericTrees);
            genericNode.setMethodName(method);
            genericNode.setValues(inputVals);
            genericNode.setOutput(input2);

            object obj = genericAnalyser.syncProcess(protocol, genericNode);

            Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
        }
Exemplo n.º 4
0
        public void testInsanity(string argument)
        {
            // Dictionary<long, Dictionary<Numberz, Insanity>>

            GenericTree input1 = new GenericTree();

            input1.setName("argument");
            input1.setParamType(TypeEnum.SYNTHETIC_TYPE);
            input1.setThrfitType("STRUCT");

            Dictionary <string, GenericTree> insanity = new Dictionary <string, GenericTree>();

            GenericTree userMap = new GenericTree();

            userMap.setName("userMap");
            userMap.setParamType(TypeEnum.COLLECTION_TYPE);
            userMap.setThrfitType("MAP");

            GenericTree xtructs = new GenericTree();

            xtructs.setName("xtructs");
            xtructs.setParamType(TypeEnum.COLLECTION_TYPE);
            xtructs.setThrfitType("LIST");

            insanity.Add("userMap", userMap);
            insanity.Add("xtructs", xtructs);


            input1.setChildren(insanity);


            List <GenericTree> inputGenericTrees = new List <GenericTree>
            {
                input1
            };

            // 参数值
            List <Object> inputVals = new List <object>();

            inputVals.Add(argument);

            //出参
            GenericTree output = new GenericTree();

            output.setParamType(TypeEnum.PRIMITIVE_TYPE);
            output.setThrfitType("STRING");
            output.setName("returnModel");

            string method = SERVICE_NAME + "testInsanity";

            GenericNode genericNode = new GenericNode();

            genericNode.setInputs(inputGenericTrees);
            genericNode.setMethodName(method);
            genericNode.setValues(inputVals);
            genericNode.setOutput(output);

            object obj = genericAnalyser.syncProcess(protocol, genericNode);

            Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
        }