コード例 #1
0
ファイル: VueWebApiModule.cs プロジェクト: Definux/Emeraude
        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 },
            }));
        }
コード例 #2
0
 private string RenderPageComponent(ModuleFile file)
 {
     return(file.RenderTemplate(new Dictionary <string, object>
     {
         { "Page", file.ReferenceId },
     }));
 }
コード例 #3
0
        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 },
            }));
        }
コード例 #4
0
        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 },
            }));
        }
コード例 #5
0
ファイル: VueWebApiModule.cs プロジェクト: Definux/Emeraude
        private string RenderTypes(ModuleFile file)
        {
            var endpointService = this.GetService <IEndpointService>();
            var classes         = endpointService.GetAllEndpointsClasses();

            return(file.RenderTemplate(new Dictionary <string, object>
            {
                { "Classes", classes },
            }));
        }
コード例 #6
0
        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) },
            }));
        }
コード例 #7
0
        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 },
            }));
        }
コード例 #8
0
        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 },
            }));
        }
コード例 #9
0
ファイル: VueWebApiModule.cs プロジェクト: Definux/Emeraude
        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 },
            }));
        }
コード例 #10
0
        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 },
            }));
        }
コード例 #11
0
        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() },
            }));
        }
コード例 #12
0
        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 },
            }));
        }
コード例 #13
0
ファイル: VueRoutesModule.cs プロジェクト: Definux/Emeraude
        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 },
            }));
        }
コード例 #14
0
        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 },
            }));
        }