using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace DkSdkCore
|
{
|
public class ApiParameters
|
{
|
private List<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>();
|
|
public List<KeyValuePair<string, string>> Value
|
{
|
get
|
{
|
return this.parameters;
|
}
|
}
|
|
public void Add(string key, string value)
|
{
|
this.parameters.Add(new KeyValuePair<string, string>(key, value));
|
}
|
|
public bool Delete(string key)
|
{
|
bool result;
|
try
|
{
|
int find = this.parameters.FindIndex((KeyValuePair<string, string> a) => a.Key == key);
|
if (find >= 0)
|
{
|
this.parameters.RemoveAt(find);
|
}
|
result = true;
|
}
|
catch
|
{
|
result = false;
|
}
|
return result;
|
}
|
|
public bool EditOrAdd(string key, string value)
|
{
|
bool result;
|
try
|
{
|
int find = this.parameters.FindIndex((KeyValuePair<string, string> a) => a.Key == key);
|
if (find >= 0)
|
{
|
this.parameters.RemoveAt(find);
|
}
|
this.Add(key, value);
|
result = true;
|
}
|
catch
|
{
|
result = false;
|
}
|
return result;
|
}
|
|
public bool Edit(string key, string value)
|
{
|
bool result;
|
try
|
{
|
int find = this.parameters.FindIndex((KeyValuePair<string, string> a) => a.Key == key);
|
if (find >= 0)
|
{
|
this.parameters.RemoveAt(find);
|
this.Add(key, value);
|
}
|
result = true;
|
}
|
catch
|
{
|
result = false;
|
}
|
return result;
|
}
|
|
public void Clear()
|
{
|
this.parameters.Clear();
|
}
|
}
|
}
|