namespace DS.Module.Core.Data
{
///
/// 任务模块之间用于传入、获取数据的容器
///
public class TaskFlowDataContext
{
private readonly Dictionary dataContext = new();
///
///
///
public TaskFlowDataContext(string key, object value)
{
dataContext.Add(key, value);
}
///
///
///
public void Set(string key, object value)
{
if (ContainsKey(key))
{
dataContext[key] = value;
}
else
{
dataContext.Add(key, value);
}
}
///
///
///
public T? Get(string key)
{
if (dataContext.ContainsKey(key))
{
return (T)dataContext[key];
}
return default;
}
///
///
///
public bool ContainsKey(string key) => dataContext.ContainsKey(key);
}
}