示例#1
0
        private static object GetParameterValue(PathParameter pathParameter, string source)
        {
            if (pathParameter.Type == typeof(string))
            {
                return(source);
            }

            if (pathParameter.Type == typeof(int))
            {
                int buffer;

                if (!int.TryParse(source, out buffer))
                {
                    return(null);
                }

                return(buffer);
            }

            if (pathParameter.Type == typeof(decimal))
            {
                decimal buffer;

                if (!decimal.TryParse(source, out buffer))
                {
                    return(null);
                }

                return(buffer);
            }

            return(null);
        }
示例#2
0
        private static object GetParameterValue(PathParameter pathParameter, string source)
        {
            if (pathParameter.Type == typeof (string))
                return source;

            if (pathParameter.Type == typeof (int))
            {
                int buffer;

                if(!int.TryParse(source, out buffer))
                    return null;

                return buffer;
            }

            if (pathParameter.Type == typeof(decimal))
            {
                decimal buffer;

                if (!decimal.TryParse(source, out buffer))
                    return null;

                return buffer;
            }

            return null;
        }