Elin Decompiled Documentation
EA 23.102 Nightly
Loading...
Searching...
No Matches
SearchContext.cs
Go to the documentation of this file.
1
using
System;
2
using
System.Collections.Generic;
3
using
System.IO;
4
5
public
class
SearchContext
6
{
7
public
class
Item
8
{
9
public
string
idFile
;
10
11
public
string
idTopic
;
12
13
public
string
text
;
14
15
public
string
textSearch
;
16
17
public
bool
system
;
18
}
19
20
public
static
int
MaxItem
= 50;
21
22
public
List<Item>
items
=
new
List<Item>();
23
24
public
List<Item>
result
=
new
List<Item>();
25
26
public
void
Init
()
27
{
28
FileInfo[] files =
new
DirectoryInfo(
CorePath
.
CorePackage
.
Help
).GetFiles();
29
foreach
(FileInfo fileInfo
in
files)
30
{
31
if
(fileInfo.Extension !=
".txt"
|| fileInfo.Name ==
"_topics.txt"
|| fileInfo.Name ==
"include.txt"
)
32
{
33
continue
;
34
}
35
string
[] array = IO.LoadTextArray(fileInfo.FullName);
36
string
idFile = fileInfo.Name.Replace(
".txt"
,
""
);
37
string
idTopic =
""
;
38
string
[] array2 = array;
39
foreach
(
string
text
in
array2)
40
{
41
if
(text.Length == 0 || text.IsEmpty() || text == Environment.NewLine)
42
{
43
continue
;
44
}
45
if
(text[0] ==
'$'
)
46
{
47
idTopic = text.Replace(
"$"
,
""
);
48
continue
;
49
}
50
bool
flag =
false
;
51
if
(text[0] ==
'{'
)
52
{
53
if
(text.Length < 6)
54
{
55
continue
;
56
}
57
switch
(text.Substring(0, 3))
58
{
59
case
"{A|"
:
60
case
"{Q|"
:
61
flag =
true
;
62
break
;
63
case
"{pa"
:
64
break
;
65
default
:
66
continue
;
67
}
68
}
69
Item
item
=
new
Item
();
70
if
(flag)
71
{
72
item.textSearch = (item.text = text.Split(
'|'
)[1].Replace(
"}"
,
""
)).ToLower();
73
}
74
else
75
{
76
item.text = text;
77
item.textSearch = text.ToLower();
78
}
79
item.idFile = idFile;
80
item.idTopic = idTopic;
81
items
.Add(
item
);
82
}
83
}
84
}
85
86
public
List<Item>
Search
(
string
s)
87
{
88
result
.Clear();
89
int
num = 0;
90
string
value = s.ToLower();
91
foreach
(
Item
item
in
items
)
92
{
93
if
(
item
.textSearch.Contains(value))
94
{
95
result
.Add(
item
);
96
num++;
97
if
(num >=
MaxItem
)
98
{
99
result
.Add(
new
Item
100
{
101
system =
true
,
102
text =
"maxResult"
.lang()
103
});
104
break
;
105
}
106
}
107
}
108
if
(
result
.Count == 0)
109
{
110
result
.Add(
new
Item
111
{
112
system =
true
,
113
text =
"noResult"
.lang()
114
});
115
}
116
return
result
;
117
}
118
}
ContainerFlag.item
@ item
CorePath.CorePackage
Definition:
CorePath.cs:48
CorePath.CorePackage.Help
static string Help
Definition:
CorePath.cs:75
CorePath
Definition:
CorePath.cs:7
SearchContext.Item
Definition:
SearchContext.cs:8
SearchContext.Item.idFile
string idFile
Definition:
SearchContext.cs:9
SearchContext.Item.idTopic
string idTopic
Definition:
SearchContext.cs:11
SearchContext.Item.system
bool system
Definition:
SearchContext.cs:17
SearchContext.Item.textSearch
string textSearch
Definition:
SearchContext.cs:15
SearchContext.Item.text
string text
Definition:
SearchContext.cs:13
SearchContext
Definition:
SearchContext.cs:6
SearchContext.Init
void Init()
Definition:
SearchContext.cs:26
SearchContext.Search
List< Item > Search(string s)
Definition:
SearchContext.cs:86
SearchContext.result
List< Item > result
Definition:
SearchContext.cs:24
SearchContext.items
List< Item > items
Definition:
SearchContext.cs:22
SearchContext.MaxItem
static int MaxItem
Definition:
SearchContext.cs:20
Elin
Plugins.UI
SearchContext.cs
Generated by
1.9.6