private ControllerMethod BuildControllerMethod(string url, Method method, Resource resource, ControllerObject parent, IDictionary <string, Parameter> parentUriParameters) { var relativeUri = UrlGeneratorHelper.GetRelativeUri(url, parent.PrefixUri); var parentUrl = UrlGeneratorHelper.GetParentUri(url, resource.RelativeUri); string b = resource.Methods.FirstOrDefault(m => m.Verb == method.Verb && m.SecuredBy != null && m.SecuredBy.Any()).SecuredBy.FirstOrDefault(); return(new ControllerMethod { Name = NetNamingMapper.GetMethodName(method.Verb ?? "Get" + resource.RelativeUri), Parameter = GetParameter(GeneratorServiceHelper.GetKeyForResource(method, resource, parentUrl), method, resource, url), UriParameters = uriParametersGenerator.GetUriParameters(resource, url, parentUriParameters), ReturnType = GetReturnType(GeneratorServiceHelper.GetKeyForResource(method, resource, parentUrl), method, resource, url), Comment = GetComment(resource, method, url), Url = relativeUri, Verb = NetNamingMapper.Capitalize(method.Verb), Parent = null, UseSecurity = raml.SecuredBy != null && raml.SecuredBy.Any() || resource.Methods.Any(m => m.Verb == method.Verb && m.SecuredBy != null && m.SecuredBy.Any()), SecuredBy = raml.SecuredBy ?? resource.Methods.FirstOrDefault(m => m.Verb == method.Verb && m.SecuredBy != null && m.SecuredBy.Any()).SecuredBy, SecurityParameters = GetSecurityParameters(raml, method) }); }
protected string GetUniqueObjectName(Resource resource, Resource parent) { string objectName; if (resource.RelativeUri.StartsWith("/{") && resource.RelativeUri.EndsWith("}")) { objectName = NetNamingMapper.Capitalize(GetObjectNameForParameter(resource)); } else { objectName = NetNamingMapper.GetObjectName(resource.RelativeUri); if (classesNames.Contains(objectName)) { objectName = NetNamingMapper.Capitalize(GetObjectNameForParameter(resource)); } } if (string.IsNullOrWhiteSpace(objectName)) { throw new InvalidOperationException("object name is null for " + resource.RelativeUri); } if (!classesNames.Contains(objectName)) { return(objectName); } if (parent == null || string.IsNullOrWhiteSpace(parent.RelativeUri)) { return(GetUniqueObjectName(objectName)); } if (resource.RelativeUri.StartsWith("/{") && parent.RelativeUri.EndsWith("}")) { objectName = NetNamingMapper.Capitalize(GetObjectNameForParameter(parent)) + objectName; } else { objectName = NetNamingMapper.GetObjectName(parent.RelativeUri) + objectName; if (classesNames.Contains(objectName)) { objectName = NetNamingMapper.Capitalize(GetObjectNameForParameter(parent)); } } if (string.IsNullOrWhiteSpace(objectName)) { throw new InvalidOperationException("object name is null for " + resource.RelativeUri); } if (!classesNames.Contains(objectName)) { return(objectName); } return(GetUniqueObjectName(objectName)); }
private static Property ConvertGeneratorParamToProperty(GeneratorParameter p) { return(new Property { Name = NetNamingMapper.Capitalize(p.Name), Description = p.Description, Type = p.Type, Required = true }); }
public static string GetPropertyName(string name) { var propName = name.Replace(":", string.Empty); propName = propName.Replace("/", string.Empty); propName = propName.Replace("-", string.Empty); propName = NetNamingMapper.Capitalize(propName); if (StartsWithNumber(propName)) { propName = "P" + propName; } return(propName); }
public static string GetNamespace(string title) { return(NetNamingMapper.Capitalize(NetNamingMapper.RemoveIndalidChars(title))); }