Exemplo n.º 1
0
        public static LoaderOptions CreateLoaderOptionsFromAgruments <TSource>(this ResolveFieldContext <TSource> context)
        {
            if (!context.HasArgument(Constants.Arguments.ARGUMENT_ALLOWFALLBACK_LANG))
            {
                throw new ArgumentException($"ResolveFieldContext does not contain any argument \"{Constants.Arguments.ARGUMENT_ALLOWFALLBACK_LANG}\"");
            }

            var allowFallbackLang = context.GetArgument <bool>(Constants.Arguments.ARGUMENT_ALLOWFALLBACK_LANG);
            var locale            = context.GetLocaleFromArgument();

            return(new LoaderOptions
            {
                allowFallbackLang
                    ? LanguageLoaderOption.Fallback(locale)
                    : LanguageLoaderOption.Specific(locale)
            });
        }