public static string CreateUriQueryForTs(string uriText, ParameterDescription[] parameterDescriptions)
        {
            var template = new UriTemplate(uriText);

            if (template.QueryValueVariableNames.Count == 0 && template.PathSegmentVariableNames.Count == 0)
            {
                return(null);
            }

            string newUriText = uriText;

            for (int i = 0; i < template.PathSegmentVariableNames.Count; i++)
            {
                var name = template.PathSegmentVariableNames[i];                //PathSegmentVariableNames[i] always give uppercase
                var d    = parameterDescriptions.FirstOrDefault(r => r.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));
                if ((d != null))
                {
                    newUriText = UriTemplateTransform.TransformForTs(newUriText, d);
                }
            }

            for (int i = 0; i < template.QueryValueVariableNames.Count; i++)
            {
                var name = template.QueryValueVariableNames[i];
                var d    = parameterDescriptions.FirstOrDefault(r => r.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));
                if ((d != null))
                {
                    newUriText = UriTemplateTransform.TransformForTs(newUriText, d);
                }
            }

            return(newUriText);
        }
        public static string CreateUriQueryForTs(string uriText, ParameterDescriptionEx[] parameterDescriptions)
        {
            UriTemplate template = new UriTemplate(uriText);

            string[] parameterNames;
            try
            {
                parameterNames = template.GetParameterNames().ToArray();
            }
            catch (ArgumentException ex)
            {
                throw new CodeGenException($"When CreateuriQuery, path {uriText} triggers error: {ex.Message}");
            }

            if (parameterNames.Length == 0 && parameterDescriptions.Length == 0)
            {
                return(null);
            }

            string newUriText = uriText;

            foreach (ParameterDescriptionEx d in parameterDescriptions)
            {
                if (d.ParameterDescriptor.ParameterBinder == ParameterBinder.FromBody || d.ParameterDescriptor.ParameterBinder == ParameterBinder.FromForm)
                {
                    continue;
                }

                newUriText = UriTemplateTransform.TransformForTs(newUriText, d);
            }

            return(newUriText);
        }
Exemple #3
0
        public static string CreateUriQueryForTs(string uriText, ParameterDescription[] parameterDescriptions)
        {
            var template       = new UriTemplate(uriText);
            var parameterNames = template.GetParameterNames().ToArray();

            if (parameterNames.Length == 0)
            {
                return(null);
            }

            string newUriText = uriText;

            for (int i = 0; i < parameterNames.Length; i++)
            {
                var name = parameterNames[i];                //PathSegmentVariableNames[i] always give uppercase
                var d    = parameterDescriptions.FirstOrDefault(r => r.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));
                Debug.Assert(d != null);
                newUriText = UriTemplateTransform.TransformForTs(newUriText, d);
            }

            return(newUriText);
        }
Exemple #4
0
        public static string CreateUriQueryForTs(string uriText, ParameterDescription[] parameterDescriptions)
        {
            var template       = new UriTemplate(uriText);
            var parameterNames = template.GetParameterNames().ToArray();

            if (parameterNames.Length == 0 && parameterDescriptions.Length == 0)
            {
                return(null);
            }

            string newUriText = uriText;

            foreach (var d in parameterDescriptions)
            {
                if (d.ParameterDescriptor.ParameterBinder == ParameterBinder.FromBody || d.ParameterDescriptor.ParameterBinder == ParameterBinder.FromForm)
                {
                    continue;
                }

                newUriText = UriTemplateTransform.TransformForTs(newUriText, d);
            }

            return(newUriText);
        }