Browse Source

add thread and dapper

master
jkpete 2 months ago
parent
commit
cbfbc584fa
  1. 2
      EGFramework.csproj
  2. 10
      Example/UsingTest/Script/EGSaveTest.cs
  3. 21
      addons/EGFramework/Module/Extension/EGDateTimeExtension.cs
  4. 20
      addons/EGFramework/Module/NodeExtension/EGNode.cs
  5. 26
      addons/EGFramework/Module/NodeExtension/EGThread.cs
  6. 8
      addons/EGFramework/Module/NodeExtension/EGTweenExtension.cs
  7. 39
      addons/EGFramework/Module/SaveTools/EGDapper.cs
  8. 5
      addons/EGFramework/Module/SaveTools/EGSqlite.cs

2
EGFramework.csproj

@ -16,5 +16,7 @@ @@ -16,5 +16,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="8.0.0" />
<PackageReference Include="LiteDB" Version="5.0.21" />
<PackageReference Include="BACnet" Version="2.0.4" />
<PackageReference Include="MySql.Data" Version="9.1.0" />
<PackageReference Include="Dapper" Version="2.1.35" />
</ItemGroup>
</Project>

10
Example/UsingTest/Script/EGSaveTest.cs

@ -6,11 +6,11 @@ using LiteDB; @@ -6,11 +6,11 @@ using LiteDB;
namespace EGFramework.Examples.Test{
public partial class EGSaveTest : Node,IEGFramework
{
public override void _Ready()
{
base._Ready();
TestCode();
}
public override void _Ready()
{
base._Ready();
TestCode();
}
public void TestSqlite(){
// string result = this.EGSqlite().CreateTable<SqliteBackpackItem>();

21
addons/EGFramework/Module/Extension/EGDateTimeExtension.cs

@ -10,11 +10,22 @@ namespace EGFramework{ @@ -10,11 +10,22 @@ namespace EGFramework{
{
return DateTime.Now.ToString("HH:mm:ss");
}
public static long GetTimeStamp(this IEGFramework self)
public static long GetDateTime(this object self)
{
TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 8, 0, 0, 0);
return System.Convert.ToInt64(ts.TotalSeconds);
DateTime dt = DateTime.Now;
return dt.Ticks;
}
public static string GetFullDateMsg(this long ticks){
DateTime dateTime = new DateTime(ticks);
return dateTime.ToString("yyyy-MM-dd") + " " + dateTime.ToString("HH:mm:ss");
}
public static string GetDayDateMsg(this long ticks){
DateTime dateTime = new DateTime(ticks);
return dateTime.ToString("HH:mm:ss");
}
public static string GetDateMsg(this long ticks){
DateTime dateTime = new DateTime(ticks);
return dateTime.ToString("yyyy-MM-dd");
}
}
}
}

20
addons/EGFramework/Module/NodeExtension/EGNode.cs

@ -25,5 +25,25 @@ namespace EGFramework{ @@ -25,5 +25,25 @@ namespace EGFramework{
}
}
public static void ClearChildren<T>(this Node itemContainer) where T : Node
{
foreach (Node child in itemContainer.GetChildren())
{
if(child.GetType()==typeof(T)){
child.QueueFree();
}
}
}
public static void ClearChildrenLabel(this Node itemContainer)
{
foreach (Node child in itemContainer.GetChildren())
{
if(child.GetType()==typeof(Label)){
child.QueueFree();
}
}
}
}
}

26
addons/EGFramework/Module/NodeExtension/EGThread.cs

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
using Godot;
using static Godot.GD;
using System;
namespace EGFramework{
public partial class EGThread : Node{
public override void _Ready()
{
base._Ready();
}
public override void _Process(double delta)
{
base._Process(delta);
}
}
public static class EGThreadExtension
{
public static void ExecuteInMainThread(this Node self, Action action){
//action.Invoke();
}
public static void ExecuteAfterSecond(this Node self, Action action,float delay){
}
}
}

8
addons/EGFramework/Module/NodeExtension/EGTweenExtension.cs

@ -5,10 +5,10 @@ namespace EGFramework.EGTween{ @@ -5,10 +5,10 @@ namespace EGFramework.EGTween{
public static class EGTweenExtension
{
#region Function
public static Tween KillOnEnd(this Tween self){
self.TweenCallback(Callable.From(self.Kill));
return self;
}
public static Tween KillOnEnd(this Tween self){
self.TweenCallback(Callable.From(self.Kill));
return self;
}
#endregion
#region Position
public static Tween TweenPosition(this Control self,Vector2 position,float delay){

39
addons/EGFramework/Module/SaveTools/EGDapper.cs

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq.Expressions;
//ORM Save tools. First support SQLite and MySQL,In future we will support other Database who implement DBConnection.
namespace EGFramework{
public class EGDapper : IEGSave, IEGSaveData
{
/// <summary>
///
/// </summary>
/// <param name="conn">files conn Str or address ip port,username and passwd</param>
public void InitSaveFile(string conn)
{
throw new System.NotImplementedException();
}
public IEnumerable<TData> FindData<TData>(string dataKey, Expression<Func<TData, bool>> expression) where TData : new()
{
throw new NotImplementedException();
}
public IEnumerable<TData> GetAll<TData>(string dataKey) where TData : new()
{
throw new NotImplementedException();
}
public TData GetData<TData>(string dataKey, object id) where TData : new()
{
throw new NotImplementedException();
}
public void SetData<TData>(string dataKey, TData data, object id)
{
throw new NotImplementedException();
}
}
}

5
addons/EGFramework/Module/SaveTools/EGSqlite.cs

@ -6,11 +6,6 @@ using Microsoft.Data.Sqlite; @@ -6,11 +6,6 @@ using Microsoft.Data.Sqlite;
using Newtonsoft.Json;
namespace EGFramework{
public interface IEGSqlite{
void SaveData<TData>(TData data) where TData : new();
List<TData> GetDataSet<TData>() where TData : new();
void InitDatabase(string dataBaseName);
}
public class EGSqlite : EGModule
{
public string DBName = "Default";

Loading…
Cancel
Save