Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
SearchContext Class Reference

Classes

class  Item
 

Public Member Functions

void Init ()
 
List< ItemSearch (string s)
 

Public Attributes

List< Itemitems = new List<Item>()
 
List< Itemresult = new List<Item>()
 

Static Public Attributes

static int MaxItem = 50
 

Detailed Description

Definition at line 5 of file SearchContext.cs.

Member Function Documentation

◆ Init()

void SearchContext.Init ( )
inline

Definition at line 26 of file SearchContext.cs.

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 }
static string Help
Definition: CorePath.cs:75
Definition: IO.cs:11
static string[] LoadTextArray(string _path)
Definition: IO.cs:470
List< Item > items

References CorePath.CorePackage.Help, item, and items.

Referenced by UIBook.Awake().

◆ Search()

List< Item > SearchContext.Search ( string  s)
inline

Definition at line 86 of file SearchContext.cs.

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 }
List< Item > result
static int MaxItem

References item, items, MaxItem, and result.

Referenced by UIBook.Search().

Member Data Documentation

◆ items

List<Item> SearchContext.items = new List<Item>()

Definition at line 22 of file SearchContext.cs.

Referenced by Init(), and Search().

◆ MaxItem

int SearchContext.MaxItem = 50
static

Definition at line 20 of file SearchContext.cs.

Referenced by Search().

◆ result

List<Item> SearchContext.result = new List<Item>()

Definition at line 24 of file SearchContext.cs.

Referenced by Search().


The documentation for this class was generated from the following file: