You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWebComponent/Dictionary.cs

104 lines
2.5 KiB
C#

3 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DSWebComponent
{
public class Dictionary
{
private static Dictionary<string, string> _dictionary = new Dictionary<string, string>();
public static Dictionary<string, string> GetDictionary()
{
return _dictionary;
}
public static void AddDictionaryItem(string key, string value)
{
if (!_dictionary.ContainsKey(key))
{
_dictionary.Add(key, value);
}
else
{
_dictionary[key] = value;
}
}
public static string GetDictionaryItem(string key)
{
string objValue = string.Empty;
string returnValue = string.Empty;
if (_dictionary.TryGetValue(key, out objValue))
{
returnValue = objValue;
}
/*else
{
returnValue = "";
}*/
return returnValue;
}
public static ArrayList GetDictionaryItemByIncomplete(string incompleteKey)
{
ArrayList returnValue = new ArrayList();
foreach (KeyValuePair<string, string> kvp in _dictionary)
{
if (kvp.Key.IndexOf(incompleteKey) != -1)
{
returnValue.Add(kvp.Key);
}
/*else
{
returnValue = "";
}*/
}
return returnValue;
}
public static bool HasItem(string key)
{
return _dictionary.ContainsKey(key);
}
public static bool ClearDictionaryItem()
{
bool succ = false;
try
{
_dictionary.Clear();
succ = true;
}
catch (Exception ex)
{
succ = true;
throw;
}
return succ;
}
public static bool RemoveDictionaryItem(string key)
{
bool succ = false;
try
{
if (key != "" && _dictionary.ContainsKey(key))
{
_dictionary.Remove(key);
}
succ = true;
}
catch (Exception ex)
{
succ = false;
throw ex;
}
return succ;
}
}
}