-
Notifications
You must be signed in to change notification settings - Fork 1
/
Class2.cs
102 lines (87 loc) · 2.41 KB
/
Class2.cs
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using System.Xml;
namespace SAST
{
public class P
{
public void C1()
{
var r = new Random(1);
}
public void C2()
{
var r = new Random();
var randomNumbers = new List<long>();
for (var i = 0; i < 6; ++i)
{
randomNumbers.Add(r.NextInt64());
}
}
public void R1_4()
{
var regex = new Regex(
pattern: "^(a+)+$",
options: RegexOptions.None
);
regex.IsMatch("");
}
public void S1_3(string url)
{
var client = new WebClient();
var data = client.DownloadDataTaskAsync(url);
}
public void S4(string url)
{
var client = new HttpClient();
var d2 = client.GetByteArrayAsync(url);
}
public void T1(string filename)
{
string baseDirectory = "base";
var fullPath = baseDirectory + "/" + filename;
var file = System.IO.File.ReadAllBytesAsync(fullPath);
}
public void T2(string filename)
{
string baseDirectory = "base";
var client = new HttpClient();
var fullPath = baseDirectory + "/" + filename;
var d2 = client.GetByteArrayAsync(fullPath);
}
public void T3(string filename)
{
string baseDirectory = "base";
var fullPath = Path.Combine(baseDirectory ,filename);
var file = System.IO.File.ReadAllBytesAsync(fullPath);
}
public class Smodel
{ }
public void U2(string json)
{
var treasure = JsonConvert.DeserializeObject<Smodel>(
json,
new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.All,
}
);
}
public void X1(string xml)
{
var doc = new XmlDocument();
doc.XmlResolver = new XmlUrlResolver();
var name = string.Empty;
doc.LoadXml(xml);
var elems = doc.GetElementsByTagName("name");
var texts = elems.Cast<XmlNode>().Select(e => e.InnerText);
name = string.Join(", ", texts);
}
}
}