Nohxi
✅ Directory path
Parameter dir
namespace Definition.Api.Parameters
{
public class Parameters : IParameters
{
private readonly IConfiguration configuration;
public Parameters(IConfiguration configuration)
{
this.configuration = configuration;
}
public string Path => configuration["Path"] ?? "";
}
}
40 replies
✅ Directory path
Repo
public class DefinitionRepository : IDefinitionRepository
{
private readonly IParameters parameters;
public DefinitionRepository(IParameters parameters)
{
this.parameters = parameters;
}
public async Task<IEnumerable<DefinitionJson>> Get()
{
string fullPath = Path.Combine(parameters.Path);
var json = File.ReadAllText(fullPath);
var searchMethod = JsonConvert.DeserializeObject<List<DefinitionJson>>(json);
return searchMethod;
}
}
40 replies
✅ Directory path
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"AppDbConnectionString": "server=localhost;database=db;User=root;Password=admin;"
},
"Path": "/Users/an/Desktop/Development/Project/Project.Api/App_data/data.json"
}
40 replies