示例#1
0
        public void SetParam <T>(Parameter parameter, T value)
        {
            var paramTypeInfo = new ParameterTypeInfo(parameter);

            if (paramTypeInfo.Type != typeof(T))
            {
                throw new ArgumentException($"Wrong return generic type argument. Must be {paramTypeInfo.Type.Name}");
            }

            paramTypeInfo.SetParamValue(this, value);
        }
示例#2
0
        public T ReadParam <T>(Parameter parameter)
        {
            var paramTypeInfo = new ParameterTypeInfo(parameter);

            if (paramTypeInfo.Type != typeof(T))
            {
                throw new ArgumentException($"Wrong return generic type argument. Must be {paramTypeInfo.Type.Name}");
            }

            var paramValue = paramTypeInfo.ReadParamValue(this);

            if (!(paramValue is T))
            {
                throw new ArgumentException("Return type of native readParam method is not equal to generic type parameter");
            }

            return((T)paramValue);
        }