heyuntao
2023-05-04 fbd6a11a99051f425640bf352842f4a0ecaa7a4d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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();
        }
    }
}