public override Composite GetComposite(ExtensionParameter profileParameter) { return(new TreeSharp.Action((x) => { if (profileParameter.Plugin.ExtensionCache.Cache.TryGetValue(Owner, out Dictionary <string, object> MyCache)) { var timerCacheString = DefaultExtension.CustomerTimerPrefix + TimerName; Stopwatch stopWatch = null; if (!MyCache.TryGetValue(timerCacheString, out object value)) { stopWatch = new Stopwatch(); MyCache[timerCacheString] = stopWatch; } else { stopWatch = (Stopwatch)value; } if (ForceStop) { // We need to start the timer, and it isn't in the cache already stopWatch.Stop(); } else { stopWatch.Restart(); } } else { profileParameter.Plugin.LogErr(Name + " is unable to get cache!", 5); } })); }
public override Func <bool> GetCondition(ExtensionParameter extensionParameter) { return(() => { if (extensionParameter.Plugin.ExtensionCache.Cache.TryGetValue(Owner, out Dictionary <string, object> MyCache)) { var timerCacheString = DefaultExtension.CustomerTimerPrefix + TimerNameString; if (MyCache.TryGetValue(timerCacheString, out object value)) { Stopwatch stopWatch = (Stopwatch)value; return stopWatch.ElapsedMilliseconds >= TimeElapsed; } else { return TrueIfStopped; } } else { extensionParameter.Plugin.LogErr(Name + " is unable to get cache!", 5); } return false; }); }