2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-26 21:13:13 +00:00

dotnet-cli

This commit is contained in:
2024-08-13 00:24:22 +03:00
parent 512b07ce8a
commit 381251fc8e
7 changed files with 128 additions and 63 deletions

View File

@ -37,27 +37,24 @@ namespace Esiur.Data;
public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
{
//private List<string> m_keys = new List<string>();
//private List<string> m_values = new List<string>();
private List<KeyValuePair<string, string>> m_Variables = new List<KeyValuePair<string, string>>();
private bool allowMultiple;
public delegate void Modified(string Key, string NewValue);
public delegate void Modified(string key, string newValue);
public event Modified OnModified;
public StringKeyList(bool AllowMultipleValues = false)
public StringKeyList(bool allowMultipleValues = false)
{
allowMultiple = AllowMultipleValues;
allowMultiple = allowMultipleValues;
}
public void Add(string Key, string Value)
public void Add(string key, string value)
{
if (OnModified != null)
OnModified(Key, Value);
OnModified(key, value);
var key = Key.ToLower();
key = key.ToLower();
if (!allowMultiple)
{
@ -71,14 +68,14 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
}
}
m_Variables.Add(new KeyValuePair<string, string>(Key, Value));
m_Variables.Add(new KeyValuePair<string, string>(key, value));
}
public string this[string Key]
public string this[string key]
{
get
{
var key = Key.ToLower();
key = key.ToLower();
foreach (var kv in m_Variables)
if (kv.Key.ToLower() == key)
return kv.Value;
@ -87,7 +84,7 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
}
set
{
var key = Key.ToLower();
key = key.ToLower();
var toRemove = m_Variables.Where(x => x.Key.ToLower() == key).ToArray();
@ -95,16 +92,15 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
m_Variables.Remove(item);
m_Variables.Add(new KeyValuePair<string, string>(Key, value));
m_Variables.Add(new KeyValuePair<string, string>(key, value));
OnModified?.Invoke(Key, value);
OnModified?.Invoke(key, value);
}
}
IEnumerator<KeyValuePair<string, string>> IEnumerable<KeyValuePair<string, string>>.GetEnumerator()
{
//return m_keys.GetEnumerator();
return m_Variables.GetEnumerator();
}
@ -122,26 +118,6 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
}
/*
public string[] Keys
{
get
{
return m_keys.ToArray();
}
}
//public Dictionary<string, string>.ValueCollection Values
public string[] Values
{
get
{
//return m_Variables.Values;
return m_values.ToArray();
}
}
*/
public List<string> GetValues(string Key)
{
@ -156,21 +132,21 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
return values;
}
public void RemoveAll(string Key)
public void RemoveAll(string key)
{
while (Remove(Key)) { }
while (Remove(key)) { }
}
public bool Remove(string Key)
public bool Remove(string key)
{
var key = Key.ToLower();
key = key.ToLower();
foreach (var kv in m_Variables)
{
if (kv.Key.ToLower() == key)
{
if (OnModified != null)
OnModified(Key, null);
OnModified(key, null);
m_Variables.Remove(kv);
return true;
}
@ -184,36 +160,24 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
get { return m_Variables.Count; }
}
public bool ContainsKey(string Key)
public bool ContainsKey(string key)
{
var key = Key.ToLower();
key = key.ToLower();
foreach (var kv in m_Variables)
if (kv.Key.ToLower() == key)
return true;
return false;
}
/*
public bool ContainsKey(string Key)
{
//return m_Variables.ContainsKey(Key);
return m_keys.Contains(Key.ToLower());
}
*/
public bool ContainsValue(string Value)
public bool ContainsValue(string value)
{
var value = Value.ToLower();
value = value.ToLower();
foreach (var kv in m_Variables)
if (kv.Value.ToLower() == value)
return true;
return false;
}
//internal KeyList()
//{
// m_Session = Session;
// m_Server = Server;
//}
}

View File

@ -63,7 +63,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.10.0" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Diagnostics.StackTrace" Version="4.3.0" />
@ -74,10 +74,10 @@
<PackageReference Include="System.Net.Security" Version="4.3.2" />
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" GeneratePathProperty="true" />
<PackageReference Include="System.Text.Json" Version="8.0.4" GeneratePathProperty="true" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
</ItemGroup>

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2017-2023 Esiur Foundation, Ahmed Kh. Zamil.
Copyright (c) 2017-2024 Esiur Foundation, Ahmed Kh. Zamil.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal