添加了手动更新标识
This commit is contained in:
@@ -8,6 +8,7 @@ using BITKit;
|
||||
using Godot;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
@@ -19,9 +20,10 @@ public interface ISearchEntry
|
||||
string Value { get; }
|
||||
}
|
||||
[Serializable]
|
||||
[Keyless]
|
||||
public class SearchResult:ISearchEntry
|
||||
{
|
||||
[Key]
|
||||
public Guid Guid { get; set; }= Guid.NewGuid();
|
||||
public string Key { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string Display { get; set; }
|
||||
@@ -31,7 +33,13 @@ public class SearchResult:ISearchEntry
|
||||
public DateTime CreateDate { get; set; }=DateTime.Now;
|
||||
}
|
||||
|
||||
public partial class SearchEngine:Node
|
||||
public interface ISearchEngine
|
||||
{
|
||||
SearchResult[] GetSearchResults(string key);
|
||||
void Add(SearchResult result);
|
||||
void Remove(string key, string id);
|
||||
}
|
||||
public partial class SearchEngine:Node,ISearchEngine
|
||||
{
|
||||
private static SqlLiteContext<SearchResult> Context;
|
||||
[Export] private Node nodeContainer;
|
||||
@@ -44,8 +52,11 @@ public partial class SearchEngine:Node
|
||||
|
||||
private readonly StringBuilder _logBuilder=new StringBuilder();
|
||||
private SearchResult[] _currentSearchResults;
|
||||
|
||||
public override async void _Ready()
|
||||
{
|
||||
BITApp.ServiceCollection.AddSingleton<ISearchEngine>(this);
|
||||
DI.Register<ISearchEngine>(this);
|
||||
try
|
||||
{
|
||||
QueueContainerFree();
|
||||
@@ -132,4 +143,17 @@ public partial class SearchEngine:Node
|
||||
x.QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
public SearchResult[] GetSearchResults(string key)=>Context.context.Where(x=>x.Key.Contains(key)).ToArray();
|
||||
|
||||
public void Add(SearchResult result)
|
||||
{
|
||||
Context.context.Add(result);
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
public void Remove(string key, string id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user