-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
214 lines (176 loc) · 5.98 KB
/
Copy pathProgram.cs
File metadata and controls
214 lines (176 loc) · 5.98 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// See https://aka.ms/new-console-template for more information
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Nuget.IdentityDatabase
{
internal class Program
{
private static void Main(string[] args)
{
string path = Path.Combine("indices.dat");
string configurationPath = Path.Combine("Configuration.json");
ContentJSON contentJSON = new();
IDENTITY_DATABASE idb = new()
{
Defident = "Man",
MultiplierA = "Socrates is a man",
MultiplierB = "All men are mortal", // man are mortal
Premise = { }
};
DATA_Сomposition_Premise trueStatement = new()
{
Proposition = "Socrates is mortal"
};
string json = JsonConvert.SerializeObject(idb, Formatting.Indented);
// Copyright
Console.WriteLine("{0} | Identity Database | INFO | IDB | InitCore() Copyright © 2023 WG Element.",
new DateTime(2023, 8, 2, 0, 0, 0, DateTimeKind.Utc));
if (File.Exists(path) && File.Exists(configurationPath))
{
Console.WriteLine("{0} | Identity Database | INFO | IDB | Файл *.dat ({1}) уже существует. Конфигурационный файл ({2}) присутствует.",
DateTime.UtcNow, path, configurationPath);
// Continue...
}
else
{
if (!File.Exists(path))
{
StreamWriter sw = File.CreateText(path);
sw.Close();
}
}
IDENTITY_DATABASE config_defaultGet = JsonConvert.DeserializeObject<IDENTITY_DATABASE>(json);
DATA_Сomposition configGet = JsonConvert.DeserializeObject<DATA_Сomposition>(contentJSON.Get_JSON(configurationPath, "data[0]"));
int dfdCharLength = configGet.Defident.Length;
string newString_Dfn1 = string.Empty;
string newString_Dfn2 = string.Empty;
if (index_Dfn1 > -1)
newString_Dfn1 = configGet.MultiplierA.Remove(index_Dfn1, dfdCharLength);
if (index_Dfn2 > -1)
newString_Dfn2 = configGet.MultiplierB.Remove(index_Dfn2, dfdCharLength);
Console.WriteLine("Dfd: {0}", configGet.Defident);
Console.WriteLine("Dfn 1: {0}", configGet.MultiplierA);
Console.WriteLine("Dfn 2: {0}", configGet.MultiplierB);
Console.WriteLine("Осмысленное произведение речи: {0}", newString_Dfn1 + newString_Dfn2);
_ = Console.ReadLine();
}
}
// Error.
/// <summary>
/// error
/// </summary>
public partial class P_API_ERROR { }
// JSON
/// <summary>
/// Работа с JSON.
/// </summary>
public partial class ContentJSON
{
/// <summary>
///
/// </summary>
/// <param name="lacal path"></param>
/// <param name="token"></param>
/// <returns></returns>
public string Get_JSON(string lacal_path, string token)
{
return ParseJSON_SelectToken(
GetResponse_TypeJSON(lacal_path),
token);
}
/// <summary>
///
/// </summary>
/// <param name="local path"></param>
/// <returns></returns>
private string GetResponse_TypeJSON(string lacal_path)
{
string result;
try
{
using StreamReader sr = new(lacal_path);
return (result = sr.ReadToEnd());
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("The configuration file could not be read:");
Console.WriteLine(e.Message);
return result = string.Empty;
}
}
/// <summary>
///
/// </summary>
/// <param name="content">JSON content</param>
/// <param name="jToken">JSON Node</param>
/// <returns></returns>
private string ParseJSON_SelectToken(string content, string jToken)
{
JObject obj = JObject.Parse(content);
string data = string.Empty;
try
{
data = obj.SelectToken(jToken).ToString();
}
catch
{
//do something
}
return data;
}
}
/// <summary>
///
/// </summary>
public partial class IDENTITY_DATABASE
{
/// <summary>
///
/// </summary>
[JsonProperty("status", Required = Required.Always)]
public bool? Status { get; set; }
/// <summary>
///
/// </summary>
[JsonProperty("data", Required = Required.Always)]
public List<DATA_Сomposition>? Data { get; set; }
}
/// <summary>
///
/// </summary>
public partial class DATA_Сomposition
{
/// <summary>
///
/// </summary>
[JsonProperty("Branch_A", Required = Required.Always)]
public long[]? BranchA { get; set; }
/// <summary>
///
/// </summary>
[JsonProperty("Branch_B", Required = Required.Always)]
public long[]? BranchB { get; set; }
/// <summary>
///
/// </summary>
[JsonProperty("Multiplier_A", Required = Required.Always)]
public string? MultiplierA { get; set; }
/// <summary>
///
/// </summary>
public string? Proposition { get; set; }
}
/// <summary>
///
/// </summary>
interface IConfigurationAppGet
{
/// <summary>
///
/// </summary>
/// <returns></returns>
bool IsOK();
}
}