mirror of
https://github.com/evopro-ag/Sharp7Reactive.git
synced 2025-12-16 11:42:52 +00:00
Cache S7 variable names
This commit is contained in:
20
Sharp7.Rx/CacheVariableNameParser.cs
Normal file
20
Sharp7.Rx/CacheVariableNameParser.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user