public static void Initialize(bool bSettingsOnly) { Console.WriteLine("Axx: Initialize"); if (Validate(Settings)) { Settings.Load(); if (Settings != null) { Console.WriteLine($"Axx: history-count-{Settings.Count()}"); } } if (bSettingsOnly) { return; } if (Validate(Entries)) { Entries.Load(); if (Entries != null) { Console.WriteLine($"Axx: data-count-{Entries.Count()}"); } } if (Validate(History)) { History.Load(); if (History != null) { Console.WriteLine($"Axx: history-count-{History.Count()}"); } } }
public bool Compute(ApplicationData currentTrade, ApplicationHistory tradeHistory) { if (!Initialize(currentTrade, tradeHistory)) { return(false); } Dictionary <ulong, ulong> computedPairs = new Dictionary <ulong, ulong>(); var dataKeys = _data.Keys.ToList(); while (dataKeys.Count > 0) { var key = dataKeys.First(); dataKeys.RemoveAt(0); if (computedPairs.Keys.Contains(key)) { continue; } ulong overrideBackedge = 0; foreach (ulong value in _data[key]) { if (key == value) { continue; } if (computedPairs.Values.Contains(value)) { continue; } ulong backEdge = 0; if (computedPairs.TryGetValue(value, out backEdge)) { if (key == backEdge) { overrideBackedge = value; continue; } } if (AddToChain(key, value)) { overrideBackedge = 0; computedPairs.Add(key, value); break; } } if (overrideBackedge != 0) { if (!SwitchChainLink(overrideBackedge, key)) { return(false); } computedPairs.Remove(overrideBackedge); computedPairs.Add(key, overrideBackedge); dataKeys.Add(overrideBackedge); } } if (_computedChain.Count != 1) { return(false); } Console.WriteLine("AdvancedShuffle:\n"); List <UserData> finalOrder = new List <UserData>(); foreach (ulong id in _computedChain.First()) { int idx; UserData dat = currentTrade.TryGetValue(id, out idx); if (dat == null) { return(false); } finalOrder.Add(dat); Console.WriteLine($"{dat.UserName} {dat.NickName}"); } if (finalOrder.Count != currentTrade.Count()) { return(false); } currentTrade.SetStorage(finalOrder); return(true); }