baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)
This commit is contained in:
commit
c2b0e7be0d
6522 files changed
+3530643
No files matched your search
Executable
+107
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Opsoft.NetCore.O3App.Shared
|
||||
{
|
||||
public class LogDictionary : IDictionary<string, object>
|
||||
{
|
||||
Dictionary<string, object> logExtraInfo = new Dictionary<string, object>();
|
||||
Dictionary<string, int> keyCounter = new Dictionary<string, int>();
|
||||
|
||||
public object this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
Guard.ArgumentNotNullOrWhiteSpace(key, nameof(key));
|
||||
if (!logExtraInfo.ContainsKey(key))
|
||||
{
|
||||
throw new KeyNotFoundException($"key dost not exist. key: {key}");
|
||||
}
|
||||
|
||||
return logExtraInfo[key];
|
||||
}
|
||||
set
|
||||
{
|
||||
logExtraInfo[key] = Guard.ArgumentNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
|
||||
public ICollection<string> Keys => logExtraInfo.Keys;
|
||||
|
||||
public ICollection<object> Values => logExtraInfo.Values;
|
||||
|
||||
public int Count => logExtraInfo.Count;
|
||||
|
||||
public bool IsReadOnly => true;
|
||||
|
||||
public void Add(string key, object value)
|
||||
{
|
||||
logExtraInfo.Add(GetUniqueKey(key), value);
|
||||
}
|
||||
|
||||
public void Add(KeyValuePair<string, object> item)
|
||||
{
|
||||
logExtraInfo.Add(GetUniqueKey(item.Key), item.Value);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
logExtraInfo.Clear();
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<string, object> item)
|
||||
{
|
||||
return logExtraInfo.ContainsKey(item.Key) && logExtraInfo[item.Key] == item.Value;
|
||||
}
|
||||
|
||||
public bool ContainsKey(string key)
|
||||
{
|
||||
return logExtraInfo.ContainsKey(key);
|
||||
}
|
||||
|
||||
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
|
||||
{
|
||||
return logExtraInfo.GetEnumerator();
|
||||
}
|
||||
|
||||
public bool Remove(string key)
|
||||
{
|
||||
return logExtraInfo.Remove(key);
|
||||
}
|
||||
|
||||
public bool Remove(KeyValuePair<string, object> item)
|
||||
{
|
||||
return logExtraInfo.Remove(item.Key);
|
||||
}
|
||||
|
||||
public bool TryGetValue(string key, out object value)
|
||||
{
|
||||
return logExtraInfo.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return logExtraInfo.GetEnumerator();
|
||||
}
|
||||
|
||||
private string GetUniqueKey(string key)
|
||||
{
|
||||
if (keyCounter.TryGetValue(key, out int count))
|
||||
{
|
||||
keyCounter[key] = ++count;
|
||||
}
|
||||
else
|
||||
{
|
||||
keyCounter[key] = count;
|
||||
}
|
||||
|
||||
return count > 0 ? $"{key}{count}" : key;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user