Files
Sharp7Reactive/Sharp7.Rx/CacheVariableNameParser.cs
2024-02-06 13:39:55 +01:00

20 lines
643 B
C#

using System;
using System.Collections.Concurrent;
using Sharp7.Rx.Interfaces;
namespace Sharp7.Rx
{
internal class CacheVariableNameParser : IS7VariableNameParser
{
private static readonly ConcurrentDictionary<string, S7VariableAddress> addressCache = new ConcurrentDictionary<string, S7VariableAddress>(StringComparer.OrdinalIgnoreCase);
private readonly IS7VariableNameParser inner;
public CacheVariableNameParser(IS7VariableNameParser inner)
{
this.inner = inner;
}
public S7VariableAddress Parse(string input) => addressCache.GetOrAdd(input, inner.Parse);
}
}