public PostgresTranslationStore(TranslationOptions options) : base(options) { GetByKeyQuery = @$ "SELECT * FROM {SchemeName}." "{TableName}" " WHERE " "Key" " = @Key AND " "Culture" " = @Culture "; InsertQuery = @$ "INSERT INTO {SchemeName}." "{TableName}" " (" "Key" "," "Value" "," "Culture" ") VALUES (@Key,@Value,@Culture)"; }
public static TranslationStore MapProviderToTranslationStore(TranslationOptions options) { return(options.Provider switch { TranslationStoreProvider.Postgres => new PostgresTranslationStore(options), _ => throw new ArgumentOutOfRangeException() });
protected TranslationStore(TranslationOptions options) { TranslationOptions = options; if (TranslationOptions == null) { throw new ArgumentNullException(nameof(TranslationOptions), "To Use Translation, You need to register TranslationOptions"); } var tableAttribute = (TableAttribute)typeof(Translation).GetCustomAttribute(typeof(TableAttribute)); SchemeName = tableAttribute?.Schema; TableName = tableAttribute?.Name; InitializeAsync().GetAwaiter().GetResult(); }
public Translator(IServiceProvider serviceProvider) { _options = serviceProvider.GetRequiredService <TranslationOptions>(); _translationStore = TranslationStoreMapper.MapProviderToTranslationStore(_options); _memoryCache = serviceProvider.GetRequiredService <IMemoryCache>(); }
public TranslationOptionsBuilder() { _translationOptions = new TranslationOptions(); }