62 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WeldingCommon.Utils
{
public class ChangeChecker
{
private static Dictionary<string, bool> mapping = new Dictionary<string, bool>();
public static bool IsChangedBool(string Resource, bool value, bool defaultVal = false)
{
if (mapping.ContainsKey(Resource) == false) {
mapping[Resource] = defaultVal;
return false;
}
if (mapping[Resource] == value) {
return false;
}
mapping[Resource] = value;
return true;
}
public static bool IsChangedBoolMonitoring(string Resource, bool value, bool MonitoringValue, bool defaultVal = false)
{
if (mapping.ContainsKey(Resource) == false) {
mapping[Resource] = defaultVal;
return false;
}
if (mapping[Resource] == value) {
return false;
}
mapping[Resource] = value;
if(mapping[Resource] == MonitoringValue)
return true;
return false;
}
private static Dictionary<string, int> mappingInt = new Dictionary<string, int>();
public static bool IsChangedInt(string Resource, int value, int defaultVal = 0)
{
if (mappingInt.ContainsKey(Resource) == false) {
mappingInt[Resource] = defaultVal;
return false;
}
if (mappingInt[Resource] == value) {
return false;
}
mappingInt[Resource] = value;
return true;
}
}
}