Ejemplo n.º 1
0
        public void CallShouldBeValidForArrayParameters()
        {
            SinTDArray parameterArray = new SinTDArray();
            parameterArray.elementType = i32;

            var serviceFunction = new ServiceFunctionDescription("arrayFunction", new SinTDType("void"));
            serviceFunction.Parameters.Add("arrayParam", parameterArray);
            service.serviceFunctions.Add("arrayFunction", serviceFunction);
            var clientFunction = connection.GenerateClientFunction("service", "arrayFunction");
            Assert.DoesNotThrow(() => clientFunction(new int[] {1, 2, 3, 4}));
        }
Ejemplo n.º 2
0
        public void CallShouldBeValidForMapParameters()
        {
            SinTDMap parameterMap = new SinTDMap();
            parameterMap.elementType = i32;
            parameterMap.keyType = SinTD_string;

            var serviceFunction = new ServiceFunctionDescription("mapFunction", new SinTDType("void"));
            serviceFunction.Parameters.Add("mapParam", parameterMap);
            service.serviceFunctions.Add("mapFunction", serviceFunction);
            var clientFunction = connection.GenerateClientFunction("service", "mapFunction");
            Assert.DoesNotThrow(() => clientFunction(new Dictionary<string, int> {
                {"first", 1},
                {"second", 2}
            }));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a SinTDTyped object and stores it under the name specified in the IDL for the corresponding parameter.
        /// The created Parameter is added to the list of parameters for the currently parsed service function object.
        /// </summary>
        /// <param name="param">String defining name and type of the parameter</param>
        /// <param name="functionDescription">Service Function object to which the parameter should be added</param>
        private void createParameterForServiceFunction(string param, ServiceFunctionDescription functionDescription)
        {
            string[] values = splitDeclarationInNameAndType(param);

            SinTDType paramType = getSinTDType(values[0].Trim());
            string paramName = values[1].Trim();
            functionDescription.Parameters.Add(paramName, paramType);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Parses parameters given for a service function in the IDL.
        /// </summary>
        /// <param name="parameterDefinition">String defining all parameters of a service funtion in the IDL</param>
        /// <param name="functionDescription">The ServiceFunction object for which the parameters are created</param>
        private void parseParameters(string parameterDefinition, ServiceFunctionDescription functionDescription)
        {
            if (parameterDefinition.Length == 0)
                return;

            // Both different parameters and key-and-value definitions of maps are separated by commata.
            // Replace the commata separating the parameters by another delimiter to avoid ambiguity and still
            // allow the MapParser to work correctly
            parameterDefinition = replaceMapKeyValueDelimiter(parameterDefinition);
            string[] parameters = parameterDefinition.Split(';');
            foreach (string param in parameters)
            {
                createParameterForServiceFunction(param.Trim(), functionDescription);
            }
        }
Ejemplo n.º 5
0
 public void CallShouldBeValidForStructParameters()
 {
     var serviceFunction = new ServiceFunctionDescription("structFunction", new SinTDType("void"));
     serviceFunction.Parameters.Add("structParam", intStruct);
     service.serviceFunctions.Add("structFunction", serviceFunction);
     var clientFunction = connection.GenerateClientFunction("service", "structFunction");
     Assert.DoesNotThrow(() => clientFunction(new testStruct { x = 1, y = 1 }));
 }
Ejemplo n.º 6
0
        public void Setup()
        {
            SinTDInstance = new SinTD();
            SinTDInstance.SINFONIServices = new ServiceRegistry();

            i32 = SinTDInstance.GetSinTDType("i32");
            SinTD_string = SinTDInstance.GetSinTDType("string");

            intStruct = new SinTDStruct("intStruct");
            intStruct.members["x"] = i32;
            intStruct.members["y"] = i32;

            serviceFunction = new ServiceFunctionDescription("function", new SinTDType("void"));
            serviceFunction.Parameters.Add("intParameter", i32);
            serviceFunction.Parameters.Add("stringParameter", SinTD_string);

            service = new SINFONIService("service");
            service.serviceFunctions.Add("function", serviceFunction);

            SinTDInstance.SINFONIServices.services.Add("service", service);
            connection = new TestConnection();
            connection.SinTD = SinTDInstance;
        }