public async Task DecrementCounterAsync(ISocketMessageChannel channel) { if (channel is IPrivateChannel) { return; } lock (Locker) { if (!Counters.ContainsKey(channel.Id)) { return; } var counter = Counters[channel.Id]; counter.Count--; if (counter.Count < 0) { counter.Count = 0; } Changes.Add(channel.Id); } }
public async Task IncrementCounterAsync(ISocketMessageChannel channel) { if (channel is IPrivateChannel) { return; } lock (Locker) { if (!Counters.ContainsKey(channel.Id)) { Counters.Add(channel.Id, new ChannelStat() { SnowflakeID = channel.Id }); } var counterForChannel = Counters[channel.Id]; counterForChannel.Count++; counterForChannel.LastMessageAt = DateTime.Now; Changes.Add(channel.Id); } }
public int Run() { while (true) { if (Pointer >= Instructions.Count) { return(0); } var instr = Instructions[Pointer]; if (!Counters.ContainsKey(Pointer)) { Counters.Add(Pointer, 0); } if (Counters[Pointer] > 0) { return(1); } Counters[Pointer]++; switch (instr) { case Acc acc: Accumulator += acc.Arg; Pointer++; break; case Jmp jmp: Pointer += jmp.Arg; break; case Nop nop: Pointer++; break; } } }
public void SubClassify(string counterNamePrefix, string path, string name, string ext, long lines) { if (ext == "jpg" || ext == "png") { // Lines count not avaialble for image files. lines = 0; } if (Counters.ContainsKey("All")) { SubClassifyHelper("All", counterNamePrefix, lines); } if (path.Contains(@"\" + "main" + @"\")) { SubClassifyHelper("Main", counterNamePrefix, lines); } if (path.Contains(@"\" + "test" + @"\")) { SubClassifyHelper("Main", counterNamePrefix, lines); } if (path.Contains(@"\" + "aaa" + @"\")) { SubClassifyHelper("AAA", counterNamePrefix, lines); } if (path.Contains(@"\" + "bbb" + @"\")) { SubClassifyHelper("BBB", counterNamePrefix, lines); } }
public int GetCounter(string name) { if (Counters.ContainsKey(name)) { return(Counters[name]); } return(1); }
public void InitCounters(IEnumerable <string> CounterNames) { foreach (string CounterName in CounterNames) { if (!Counters.ContainsKey(CounterName)) { Counters.Add(CounterName, 0); } } }
public void IncrementCounter(CounterIds ids, int num) { lock (_CounterLock) { if (!Counters.ContainsKey(ids)) { return; } Counters[ids] += num; } }
public int ReadCounter(CounterIds ids) { lock (_CounterLock) { if (!Counters.ContainsKey(ids)) { return(0); } return(Counters[ids]); } }
public Tuple <int, long, DateTime> GetValue(ulong channelID) { if (!Counters.ContainsKey(channelID)) { return(new Tuple <int, long, DateTime>(0, 0, DateTime.MinValue)); } var orderedData = Counters.OrderByDescending(o => o.Value.Count).ToDictionary(o => o.Key, o => o.Value); var position = orderedData.Keys.ToList().FindIndex(o => o == channelID) + 1; var channel = Counters[channelID]; return(new Tuple <int, long, DateTime>(position, channel.Count, channel.LastMessageAt)); }
public void IncrementCount(string CountName) { lock (DataLock) { if (Counters.ContainsKey(CountName)) { Counters[CountName]++; } else { Counters.Add(CountName, 1); } } }
public void FilterFailure(string source, int index, bool lastResult, Action <bool> ExecuteOperation) { if (Counters.ContainsKey(source) == false || index > Counters[source].Count()) { Trace($"FFH. FilterFailure Error;{source};{index};{ToString()}"); return; } var counter = Counters[source]; counter[index] = lastResult == true ? 0 : (counter[index]) + 1; var result = counter[index] >= ConsecutiveFailsLimit ? false : true; Trace($"FFH. FilterFailure;{source};{index};{counter[index]};{lastResult};{result}"); ExecuteOperation(result); }
public static void countwords(string[] words) { foreach (var word in words) { string sortedWord = String.Concat(word.OrderBy(c => c)); if (!Counters.ContainsKey(sortedWord)) { Counters.Add(sortedWord, 0); wordsToABC.Add(word, sortedWord); } Counters[sortedWord] += 1; } }
public void LoadOrReload(List <string> sources) { sources.ForEach(s => { // Añadimos los no existentes. if (Counters.ContainsKey(s) == false) { Counters[s] = new int[InitialValue.Count()]; Array.Copy(InitialValue, Counters[s], InitialValue.Count()); } }); // Borramos los no Existentes. var missings = Counters.Keys.Where(k => sources.Contains(k) == false).ToList(); missings.ForEach(k => Counters.Remove(k)); Trace($"FFH. LoadOrReload;;;{ToString()}"); }
public void SubClassifyHelper(string groupName, string counterNamePrefix, long lines) { string counterNameLines = counterNamePrefix + "Lines"; string counterNameFiles = counterNamePrefix + "Files"; if (Counters.ContainsKey(groupName)) { var groupCounters = Counters[groupName]; if (groupCounters.ContainsKey(counterNameLines)) { groupCounters[counterNameLines] += lines; } if (groupCounters.ContainsKey(counterNameFiles)) { groupCounters[counterNameFiles]++; } } }
private void EventPostProcess(string name) { AppLogger.LogInformation($"Logger event {name} triggered."); if (!Counters.ContainsKey(name)) { Counters.Add(name, 1); } else { Counters[name]++; } lock (LastEventLock) { LastEvent = name; LastEventAt = DateTime.UtcNow; } }
private void FinalizeCountHelper(string groupName, string counterNamePrefix) { string counterNameLines = counterNamePrefix + "Lines"; string counterNameFiles = counterNamePrefix + "Files"; if (Counters.ContainsKey(groupName)) { var groupCounters = Counters[groupName]; if (groupCounters.ContainsKey(counterNameLines)) { if (counterNamePrefix != "Image") { // Lines count not avaialble for image files. groupCounters["GrandTotalLines"] += groupCounters[counterNameLines]; } } if (groupCounters.ContainsKey(counterNameFiles)) { groupCounters["GrandTotalFiles"] += groupCounters[counterNameFiles]; } } }
public long GetEvaluationsCount(EvaluationStatus status) { return((Counters == null || !Counters.ContainsKey(status)) ? 0 : Counters[status]); }
public long GetMembershipsCount(MembershipStatus status) { return((Counters == null || !Counters.ContainsKey(status)) ? 0 : Counters[status]); }