Example #1
0
        public static string[] SerializeParameterTypes(Type[] parametersTypes)
        {
            // not using linq on purpose

            var names = new string[parametersTypes.Length];

            for (int i = 0; i < parametersTypes.Length; i++)
            {
                names[i] = TypeShortnameLookup.GetName(parametersTypes[i]);
            }

            return(names);
        }
Example #2
0
        public static ResponseMessage BuildResponse(Tuple <object, Type> result)
        {
            if (result.Item2 == typeof(void))
            {
                return(ResponseMessage.Empty);
            }

            if (ReflectionUtils.IsCollectionType(result.Item2))
            {
                var elements   = ReflectionUtils.NormalizeToArray(result.Item1, result.Item2);
                var serialized = Serialization.SerializeArray(elements);
                return(new ResponseMessage(serialized, TypeShortnameLookup.GetName(result.Item2), null));
            }
            if (result.Item1 != null)
            {
                var tuple = Serialization.BuildParamTuple(result.Item2, result.Item1);
                return(new ResponseMessage(tuple.SerializedValue, tuple.TypeName, null));
            }

            return(ResponseMessage.Empty);
        }