private static II18NServiceCollection AddJsonResourceFromOnce(II18NServiceCollection services, string path, bool referenceToBasePath) { try { using (var adapter = new JsonFileAdapter(PathHelper.Combine(services.ExposeOptions, path, referenceToBasePath))) { if (adapter.Process()) { var speaker = adapter.Speak(); var language = speaker.Language; services.ExposeOptions.AddResource(language, LanguageResourceFactory.Create(speaker)); } } } catch (Exception exception) { InternalLogger.WriteLine($"Thrown exception when add xml resource from {path}, message: {0}", exception.Message); } return(services); }
public static II18NServiceCollection AddXmlResource(this II18NServiceCollection services, string originContext) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (string.IsNullOrWhiteSpace(originContext)) { throw new ArgumentNullException(nameof(originContext)); } using (var adapter = new XmlContentAdapter(originContext)) { if (adapter.Process()) { var speaker = adapter.Speak(); var language = speaker.Language; services.ExposeOptions.AddResource(language, LanguageResourceFactory.Create(speaker)); } } return(services); }