using Quadarax.Foundation.Core.QConsole; using Quadarax.Foundation.Core.QConsole.Attributes; using Quadarax.Foundation.Core.Value; namespace Quadarax.Foundation.Core.QMonitor.Console.Commands { [CommandDefinition] internal class ScanCommand : BaseCommand { #region *** Constants *** private const string CS_CMD_SCAN_NAME = "scan"; private const string CS_CMD_SCAN_DESC = "Scans for general metadata informations."; #endregion #region *** Properties *** public override string Name => CS_CMD_SCAN_NAME; public override string Description => CS_CMD_SCAN_DESC; #endregion #region *** Private fields *** private IDictionary _cachedGenerals = new Dictionary(); #endregion #region *** Constructor *** public ScanCommand(Engine engine) : base(engine) { } #endregion #region *** Execute *** protected override Result OnExecute() { var waitToData = TimeSpan.FromSeconds(10); WriteInfo($"Waiting for collecting general metadata {waitToData.TotalSeconds} seconds..."); Task.Delay(waitToData).Wait(); WriteInfo($"Collected {_cachedGenerals.Count} items above."); return new Result(); } #endregion #region *** Private Operations *** protected override void OnGeneralReceived(MonGeneral general) { foreach (var item in general.Items) { if(!_cachedGenerals.ContainsKey($"{general.InstanceIdentifier}_{item.Name}")) { _cachedGenerals.Add($"{general.InstanceIdentifier}_{item.Name}", item); WriteInfo("[" + general.InstanceIdentifier + "] " + item.Name); } } } #endregion } }