BadScript 2
Loading...
Searching...
No Matches
BadFileSystemStackConfig.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.IO;
4using Newtonsoft.Json.Linq;
5
7{
9 {
10 public string? Name { get; set; }
11 public string Type { get; set; } = string.Empty;
12 public string Source { get; set; } = string.Empty;
13 public string? Target { get; set; }
14
15 public static BadFileSystemStackConfig[] FromFile(string path)
16 {
17 List<BadFileSystemStackConfig> configs = new List<BadFileSystemStackConfig>();
18 var lines = File.ReadAllLines(path);
19 foreach (var line in lines)
20 {
21 if (!string.IsNullOrEmpty(line))
22 {
23 continue;
24 }
25 configs.Add(Parse(line));
26 }
27
28 return configs.ToArray();
29 }
30
31 public static BadFileSystemStackConfig Parse(string line)
32 {
33 var parts = line.Split('|');
34 if (parts.Length != 2 && parts.Length != 3)
35 {
36 throw new Exception("Invalid Format");
37 }
38 var type = parts[0];
39 var source = parts[1];
40 var target = "/";
41 if (parts.Length == 3)
42 {
43 target = parts[2];
44 }
45
47 {
48 Type = type,
49 Source = source,
50 Target = target
51 };
52 }
53 }
54}
static BadFileSystemStackConfig[] FromFile(string path)
static BadFileSystemStackConfig Parse(string line)