MetaData.cs
1.68 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MoyaAdminLib
{
public class MetaData
{
public string key;
public string value;
public static MetaData GetValue(string ret)
{
MetaData data = null;
if (ret != null && ret != "")
{
ret = ret.Trim();
if (ret.StartsWith("{") && ret.EndsWith("}"))
{
ret = ret.Replace("{", "");
ret = ret.Replace("}", "");
if (ret.Contains(":"))
{
data = new MetaData();
string[] fields = ret.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
if (fields.Length == 2)
{
if (fields[0].StartsWith("\""))
fields[0] = fields[0].Substring(1, fields[0].Length - 1);
if (fields[0].EndsWith("\""))
fields[0] = fields[0].Substring(0, fields[0].Length - 1);
data.key = fields[0];
if (fields[1].StartsWith("\""))
fields[1] = fields[1].Substring(1, fields[1].Length - 1);
if (fields[1].EndsWith("\""))
fields[1] = fields[1].Substring(0, fields[1].Length - 1);
data.value = fields[1];
}
}
}
}
return data;
}
}
}