Query query = userStatsDatabase..orderByChild("Weight/Month");
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot monthSnapshot: dataSnapshot.getChildren()) {
System.out.println(monthSnapshot.getKey()); // August, September, October
System.out.println(monthSnapshot.child("Weight/Month").getValue(Long.class)); // 8, 9, 10
}
}
...
///////////////////////////////////////////////// ///////////////////////////////////////////////////// ///////////////////////
public class Logger : ILogger
{
private readonly ILoggerHandler LoggerH;
public Logger(ILoggerHandler _LoggerH)
{
LoggerH = _LoggerH;
}
public async Task exception(LogObj _log)
{
await LoggerH.Log(_log); // Called ILoggerHandler Method
}
}
public interface ILogger
{
Task exception(LogObj _log);
}
///////////////////////////////////////////////// ///////////////////////////////////////////////////// ///////////////////////////////
public interface ILoggerHandler
{
Task Log(LogObj log);
}
public class LoggerHandler: ILoggerHandler
{
private readonly IAPIHandler _apiHandler;
public LoggerHandler(IAPIHandler apiHandler)
{
_apiHandler = apiHandler;
}
public async Task Log(LogObj log)
{
try
{
var request = JsonConvert.SerializeObject(log);
await _apiHandler.Process(request, url, HttpMethode.POST, _headers); // Called IAPIHandler Method
}
catch (Exception ex)
{
}
}
}
所以这导致循环依赖,因此需要帮助来解决