Ejemplo n.º 1
0
        /// <summary>
        /// Generates a client function for the <paramref name="funcName"/>. Optional <paramref name="typeMapping"/> string
        /// may be used to specify data omission and reordering options.
        /// </summary>
        /// <returns>The generated client function.</returns>
        /// <param name="serviceName">Service that contains the wrapped function.</param>
        /// <param name="functionName">Name of the function that should be wrapped.</param>
        public virtual ClientFunction GenerateClientFunction(string serviceName, string functionName)
        {
            if (!SinTD.SINFONIServices.ContainsService(serviceName))
            {
                throw new ServiceNotRegisteredException(serviceName);
            }

            var service = SinTD.SINFONIServices.GetService(serviceName);

            if (!service.ContainsServiceFunction(functionName))
            {
                throw new ServiceNotRegisteredException(functionName);
            }

            return((ClientFunction) delegate(object[] parameters)
            {
                SINFONIService registeredService = SinTD.SINFONIServices.GetService(serviceName);
                ServiceFunctionDescription registeredServiceFunction = registeredService.GetServiceFunction(functionName);

                if (!registeredServiceFunction.CanBeCalledWithParameters(parameters))
                {
                    throw new ParameterMismatchException(
                        "Could not call Service Function " + serviceName + "." + functionName
                        + ". The provided parameters can not be mapped to the parameters specified in the IDL.");
                }
                object[] callParameters = new object[parameters.Length];
                for (var i = 0; i < parameters.Length; i++)
                {
                    SinTDType expectedParameterType = registeredServiceFunction.Parameters.ElementAt(i).Value;
                    callParameters[i] = expectedParameterType.AssignValuesFromObject(parameters[i]);
                }
                return CallClientFunction(serviceName + "." + functionName, callParameters);
            });
        }
Ejemplo n.º 2
0
        private object getFieldValueForSinTDInstance(object other, string fieldName, SinTDType SinTDType)
        {
            var assignedValue = other;
            var otherField    = other.GetType().GetField(fieldName);

            if (otherField == null)
            {
                var property = other.GetType().GetProperty(fieldName);
                assignedValue = SinTDType.AssignValuesFromObject(property.GetValue(other, null));
            }
            else
            {
                assignedValue = SinTDType.AssignValuesFromObject(otherField.GetValue(other));
            }
            return(assignedValue);
        }
Ejemplo n.º 3
0
        private object getFieldValueForSinTDInstance(object other, string fieldName, SinTDType SinTDType)
        {
            var assignedValue = other;
            var otherField = other.GetType().GetField(fieldName);

            if (otherField == null)
            {
                var property = other.GetType().GetProperty(fieldName);
                assignedValue = SinTDType.AssignValuesFromObject(property.GetValue(other, null));
            }
            else
            {
                assignedValue = SinTDType.AssignValuesFromObject(otherField.GetValue(other));
            }
            return assignedValue;
        }