1313namespace SmartImage . Lib . Results ;
1414
1515public sealed record SearchResultItem : IDisposable ,
16- IComparable < SearchResultItem > , IComparable ,
17- IValidity < SearchResultItem >
16+ IComparable < SearchResultItem > , IComparable ,
17+ IValidity < SearchResultItem >
1818{
19+
1920 private bool m_isScored ;
2021
2122 public const int MAX_SCORE = 13 ;
@@ -109,12 +110,25 @@ public sealed record SearchResultItem : IDisposable,
109110 [ CBN ]
110111 public SearchResultItem Parent { get ; internal set ; }
111112
112- public List < SearchResultItem > Children { get ; internal set ; }
113+ // public List<SearchResultItem> Children { get; internal set; }
113114
114115 // public bool IsUniType { get; internal set; }
115116
116117 public bool IsRaw { get ; internal set ; }
117118
119+ public bool Equals ( SearchResultItem other )
120+ {
121+ if ( ReferenceEquals ( null , other ) ) return false ;
122+ if ( ReferenceEquals ( this , other ) ) return true ;
123+
124+ return Root . Equals ( other . Root ) && Uni == other . Uni ;
125+ }
126+
127+ public override int GetHashCode ( )
128+ {
129+ return HashCode . Combine ( Root , Uni ) ;
130+ }
131+
118132 internal SearchResultItem ( SearchResult r )
119133 {
120134 Root = r ;
@@ -123,7 +137,7 @@ internal SearchResultItem(SearchResult r)
123137 Uni = null ;
124138 Parent = null ;
125139 IsRaw = false ;
126- Children = [ ] ;
140+ // Children = [];
127141 }
128142
129143 /*
@@ -146,12 +160,6 @@ internal SearchResultItem[] FromUni()
146160 return u;
147161 }
148162 */
149- internal static SearchResultItem GetRaw ( SearchResult r )
150- => new SearchResultItem ( r )
151- {
152- IsRaw = true ,
153- Url = r . RawUrl
154- } ;
155163
156164 public static bool IsValid ( [ CBN ] SearchResultItem r )
157165 {
@@ -197,6 +205,7 @@ public void UpdateScore()
197205 m_isScored = true ;
198206 }
199207
208+ /*
200209 public void AddChildren(string[] rg)
201210 {
202211 for (int i = 0; i < rg.Length; i++) {
@@ -212,6 +221,25 @@ public void AddChildren(string[] rg)
212221 }
213222
214223 }
224+ */
225+ public SearchResultItem [ ] AddChildren ( string [ ] rg )
226+ {
227+ var rg2 = new SearchResultItem [ rg . Length ] ;
228+
229+ for ( int i = 0 ; i < rg . Length ; i ++ ) {
230+
231+ rg2 [ i ] = new SearchResultItem ( this )
232+ {
233+ Url = rg [ i ] ,
234+ // Children = [],
235+ Parent = this ,
236+ } ;
237+
238+ // Children.Add(sri);
239+ }
240+
241+ return rg2 ;
242+ }
215243
216244 // [MustUseReturnValue]
217245 public async Task < bool > LoadUniAsync ( CancellationToken ct = default )
@@ -271,8 +299,8 @@ public int CompareTo(object obj)
271299 if ( ReferenceEquals ( this , obj ) ) return 0 ;
272300
273301 return obj is SearchResultItem other
274- ? CompareTo ( other )
275- : throw new ArgumentException ( $ "Object must be of type { nameof ( SearchResultItem ) } ") ;
302+ ? CompareTo ( other )
303+ : throw new ArgumentException ( $ "Object must be of type { nameof ( SearchResultItem ) } ") ;
276304 }
277305
278306 public static bool operator < ( SearchResultItem left , SearchResultItem right )
@@ -296,4 +324,5 @@ public int CompareTo(object obj)
296324 }
297325
298326 #endregion
327+
299328}
0 commit comments