Esempio n. 1
0
        public void Title_Changed()
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                return;
            }

            SelectNewRamlOption();
            NewRamlFilename  = NetNamingMapper.RemoveInvalidChars(Title) + RamlFileExtension;
            NewRamlNamespace = GetNamespace(NewRamlFilename);
        }
        protected IEnumerable <GeneratorParameter> ExtractParametersFromUrl(string url)
        {
            var parameters = new List <GeneratorParameter>();

            if (string.IsNullOrWhiteSpace(url) || !url.Contains("{"))
            {
                return(parameters);
            }

            var regex   = new Regex("{([^}]+)}");
            var matches = regex.Matches(url);

            parameters.AddRange(matches.Cast <Match>().Select(match =>
                                                              new GeneratorParameter {
                OriginalName = match.Groups[1].Value,
                Name         = NetNamingMapper.Capitalize(NetNamingMapper.RemoveInvalidChars(match.Groups[1].Value)),
                Type         = "string"
            })
                                .ToArray());
            return(parameters);
        }
        public IEnumerable <GeneratorParameter> GetUriParameters(EndPoint resource, string url, IDictionary <string, Parameter> parentUriParameters)
        {
            if (resource == null || resource.Parameters == null)
            {
                return(new List <GeneratorParameter>());
            }

            var parameters = resource.Parameters.Where(p => p != null)
                             .Select(p => new GeneratorParameter {
                OriginalName = p.Name,
                Name         = NetNamingMapper.Capitalize(NetNamingMapper.RemoveInvalidChars(p.Name)),
                Type         = p.Schema != null ? NewNetTypeMapper.GetNetType(p.Schema) : "string",
                Description  = p.Description
            })
                             .ToList();

            var urlParameters        = ExtractParametersFromUrl(url).ToArray();
            var distincUrlParameters = urlParameters.Where(up => parameters.All(p => up.Name != p.Name)).ToArray();

            var matchedParameters = MatchParameters(parentUriParameters, distincUrlParameters);

            parameters.AddRange(matchedParameters);
            return(parameters);
        }
Esempio n. 4
0
 public void Should_Generate_Random_Values()
 {
     Assert.AreNotEqual(NetNamingMapper.RemoveInvalidChars(">"), NetNamingMapper.RemoveInvalidChars("<"));
 }
Esempio n. 5
0
 private static GeneratorParameter ConvertAmfParameterToGeneratorParameter(Parameter parameter)
 {
     return(new GeneratorParameter {
         OriginalName = parameter.Name, Name = NetNamingMapper.Capitalize(NetNamingMapper.RemoveInvalidChars(parameter.Name)), Type = NewNetTypeMapper.GetNetType(parameter.Schema), Description = parameter.Description
     });
 }