/// <summary> /// Record the activation of an action. /// </summary> /// <param name="key">Key of this action.</param> public void Activate(string key) { if (!records.TryGetValue(key, out ActivationRecord rec)) { rec = new ActivationRecord() { Key = key, LastActivationVersion = Package.Current.Id.Version, ActivationCount = 0, } } ; rec.ActivationCount += 1; rec.LastActivationTime = DateTime.Now; records[key] = rec; }
/// <summary> /// Try to get the record with specific key. /// </summary> /// <param name="key">Key of the target record.</param> /// <param name="record">The output record.</param> /// <returns> /// True is returned if there is a record stored. /// False means the record with given key is not found. /// Action with that key might be not ever activated, /// or might be dropped because of the capacity limit. /// </returns> public bool TryGetRecord(string key, out ActivationRecord record) => records.TryGetValue(key, out record);