private string RenderEnums(ModuleFile file) { var endpointService = this.GetService <IEndpointService>(); var classes = endpointService.GetAllEndpointsClasses(); var enums = DescriptionExtractor.ExtractUniqueEnumsFromClasses(classes); var enumValueItems = new Dictionary <string, string>(); DefaultContractResolver contractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy(), }; foreach (var enumItem in enums) { string serializedEnums = JsonConvert.SerializeObject( EnumFunctions.GetEnumValueItems(enumItem.FullName), new JsonSerializerSettings { ContractResolver = contractResolver, Formatting = Formatting.Indented, }); enumValueItems[enumItem.FullName] = JToken.Parse(serializedEnums).ToString(); } return(file.RenderTemplate(new Dictionary <string, object> { { "Enums", enums }, { "EnumsValueItems", enumValueItems }, })); }
private string RenderPageComponent(ModuleFile file) { return(file.RenderTemplate(new Dictionary <string, object> { { "Page", file.ReferenceId }, })); }
private string RenderConstants(ModuleFile file) { var constantDictionaries = this.Options.ConstantsTypes .ToDictionary( tk => tk.Name, tv => tv.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) .Where(xx => xx.IsLiteral && !xx.IsInitOnly) .ToDictionary( k => StringFunctions.ConvertToKey(k.Name), v => this.ConvertToJavaScriptValue(v.GetRawConstantValue()))); if (this.Options.Constants.Count > 0) { constantDictionaries["ConstantsExposedByTheApplication"] = this.Options.Constants .ToDictionary( x => StringFunctions.ConvertToKey(x.Key), x => this.ConvertToJavaScriptValue(x.Value)); } return(file.RenderTemplate(new Dictionary <string, object> { { "Constants", constantDictionaries }, })); }
private string RenderTranslations(ModuleFile file) { var languageStore = this.GetService <ILanguageStore>(); var translationsDictionary = languageStore.GetLanguageTranslationDictionary(int.Parse(file.ReferenceId)); return(file.RenderTemplate(new Dictionary <string, object> { { "Translations", translationsDictionary }, })); }
private string RenderTypes(ModuleFile file) { var endpointService = this.GetService <IEndpointService>(); var classes = endpointService.GetAllEndpointsClasses(); return(file.RenderTemplate(new Dictionary <string, object> { { "Classes", classes }, })); }
private string RenderDto(ModuleFile file) { var endpointService = this.GetService <IEndpointService>(); var classes = endpointService.GetAllEndpointsClasses(); return(file.RenderTemplate(new Dictionary <string, object> { { "Class", classes.FirstOrDefault(x => x.FullName == file.ReferenceId) }, })); }
private string RenderTranslationsKeys(ModuleFile file) { var languageStore = this.GetService <ILanguageStore>(); var translationsKeys = languageStore.GetTranslationsKeys(); var translationsKeysDictionary = translationsKeys.ToDictionary(k => this.MakePascalCaseKeyFromTranslationKey(k), v => v); return(file.RenderTemplate(new Dictionary <string, object> { { "TranslationsKeys", translationsKeysDictionary }, })); }
private string RenderTranslationsBase(ModuleFile file) { var languageStore = this.GetService <ILanguageStore>(); var defaultLanguage = languageStore.GetDefaultLanguage(); var translationsDictionary = languageStore.GetLanguageTranslationDictionary(defaultLanguage.Id); return(file.RenderTemplate(new Dictionary <string, object> { { "Translations", translationsDictionary }, })); }
private string RenderEndpoints(ModuleFile file) { var endpointService = this.GetService <IEndpointService>(); var endpoints = endpointService.GetAllEndpoints(); return(file.RenderTemplate(new Dictionary <string, object> { { "EndpointsControllers", endpoints.Select(x => x.ControllerName).Distinct().ToList() }, { "Endpoints", endpoints }, })); }
private string RenderEnums(ModuleFile file) { var endpointService = this.GetService <IEndpointService>(); var classes = endpointService.GetAllEndpointsClasses(); var enums = DescriptionExtractor.ExtractUniqueEnumsFromClasses(classes); return(file.RenderTemplate(new Dictionary <string, object> { { "Enums", enums }, })); }
private string RenderServiceAgentInterface(ModuleFile file) { var endpointService = this.GetService <IEndpointService>(); var endpoints = endpointService.GetAllEndpoints(); return(file.RenderTemplate(new Dictionary <string, object> { { "EndpointsController", file.ReferenceId.Replace("ApiController", string.Empty).ToFirstUpper() }, { "Endpoints", endpoints.Where(x => x.ControllerName == file.ReferenceId).ToList() }, })); }
private string RenderConfigFile(ModuleFile file) { var localizationContext = this.GetService <ILocalizationContext>(); var languages = localizationContext.Languages.ToList(); Language defaultLanguage = languages.FirstOrDefault(x => x.IsDefault); return(file.RenderTemplate(new Dictionary <string, object> { { "Languages", languages }, { "DefaultLanguage", defaultLanguage }, })); }
private string RenderRouterList(ModuleFile file) { var pageService = this.GetService <IPageService>(); var languageStore = this.GetService <ILanguageStore>(); var pages = pageService.GetAllPages(); var languages = languageStore.GetLanguages(); var languageRouteRegex = string.Join('|', languages.Where(x => !x.IsDefault).Select(x => x.Code.ToLower())); return(file.RenderTemplate(new Dictionary <string, object> { { "Pages", pages }, { "LanguageRouteRegex", languageRouteRegex }, { "SingleLanguage", languages.Count() < 2 }, })); }
private string RenderStaticContent(ModuleFile file) { var localizationContext = this.GetService <ILocalizationContext>(); Language defaultLanguage = localizationContext.Languages.FirstOrDefault(x => x.IsDefault); ContentKey staticContentKeyWithContent = localizationContext .ContentKeys .Where(x => x.Id == int.Parse(file.ReferenceId)) .Include(x => x.StaticContentList) .FirstOrDefault(); return(file.RenderTemplate(new Dictionary <string, object> { { "Key", staticContentKeyWithContent }, { "DefaultLanguage", defaultLanguage }, })); }