48 changed files with 468 additions and 11 deletions
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 2a48c7d10c6089e4bb6e64111fb6bf6a |
||||||
|
folderAsset: yes |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 14094f78fb2f4e14dbd21a413f1692f9 |
||||||
|
folderAsset: yes |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
Binary file not shown.
@ -0,0 +1,7 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 48e32ca49f7fdd646ada9addf65fbe3f |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 4b8a2f5e75555654bb2bb7f8ebc41d49 |
||||||
|
folderAsset: yes |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: f2744b513842f984a9d48b88f16b2312 |
||||||
|
folderAsset: yes |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
Binary file not shown.
@ -0,0 +1,33 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: c5ec07acbec7e284798856cc34f732b2 |
||||||
|
PluginImporter: |
||||||
|
externalObjects: {} |
||||||
|
serializedVersion: 2 |
||||||
|
iconMap: {} |
||||||
|
executionOrder: {} |
||||||
|
defineConstraints: [] |
||||||
|
isPreloaded: 0 |
||||||
|
isOverridable: 0 |
||||||
|
isExplicitlyReferenced: 0 |
||||||
|
validateReferences: 1 |
||||||
|
platformData: |
||||||
|
- first: |
||||||
|
Any: |
||||||
|
second: |
||||||
|
enabled: 1 |
||||||
|
settings: {} |
||||||
|
- first: |
||||||
|
Editor: Editor |
||||||
|
second: |
||||||
|
enabled: 0 |
||||||
|
settings: |
||||||
|
DefaultValueInitialized: true |
||||||
|
- first: |
||||||
|
Windows Store Apps: WindowsStoreApps |
||||||
|
second: |
||||||
|
enabled: 0 |
||||||
|
settings: |
||||||
|
CPU: AnyCPU |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 4a23589c1db39354cb54493bd3bd664a |
||||||
|
folderAsset: yes |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 2c7078626b1ca6d4e88f5ea9d7d9a660 |
||||||
|
folderAsset: yes |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: b99dda3f97115a843bdb608d51ec1648 |
||||||
|
folderAsset: yes |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 5cd35fec940c4cb89f79b6c66901008e |
||||||
|
timeCreated: 1735992114 |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 0fa6f94e2e704e0faeac90ef8e185f2f |
||||||
|
timeCreated: 1735992174 |
@ -0,0 +1,31 @@ |
|||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace Tools.Editor.CodeGenKit |
||||||
|
{ |
||||||
|
public abstract class CodeScope : ICodeScope |
||||||
|
{ |
||||||
|
public bool Semicolon { get; set; } |
||||||
|
|
||||||
|
public virtual void Gen(ICodeWriter writer) |
||||||
|
{ |
||||||
|
GenFirstLine(writer); |
||||||
|
|
||||||
|
new OpenBraceCode().Gen(writer); |
||||||
|
|
||||||
|
writer.IndentCount++; |
||||||
|
|
||||||
|
foreach (var code in Codes) |
||||||
|
{ |
||||||
|
code.Gen(writer); |
||||||
|
} |
||||||
|
|
||||||
|
writer.IndentCount--; |
||||||
|
|
||||||
|
new CloseBraceCode(Semicolon).Gen(writer); |
||||||
|
} |
||||||
|
|
||||||
|
protected abstract void GenFirstLine(ICodeWriter writer); |
||||||
|
|
||||||
|
public List<ICode> Codes { get; } = new(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 737f0286aef24e158bf957af85f06c15 |
||||||
|
timeCreated: 1735992259 |
@ -0,0 +1,7 @@ |
|||||||
|
namespace Tools.Editor.CodeGenKit |
||||||
|
{ |
||||||
|
public interface ICode |
||||||
|
{ |
||||||
|
void Gen(ICodeWriter writer); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 5b930fc6d1d247949af8177d796c4265 |
||||||
|
timeCreated: 1735992194 |
@ -0,0 +1,9 @@ |
|||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace Tools.Editor.CodeGenKit |
||||||
|
{ |
||||||
|
public interface ICodeScope : ICode |
||||||
|
{ |
||||||
|
List<ICode> Codes { get; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 249dc2e076114187958bc580f2455fec |
||||||
|
timeCreated: 1735992236 |
@ -0,0 +1,8 @@ |
|||||||
|
namespace Tools.Editor.CodeGenKit |
||||||
|
{ |
||||||
|
public interface ICodeWriter |
||||||
|
{ |
||||||
|
int IndentCount { get; set; } |
||||||
|
void WriteLine(string code = null); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 96536dd301a640eba7ff5c8d8a597663 |
||||||
|
timeCreated: 1735992216 |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 2362665fe861427fb3d22bfc213e7543 |
||||||
|
timeCreated: 1735992283 |
@ -0,0 +1,43 @@ |
|||||||
|
using System; |
||||||
|
|
||||||
|
namespace Tools.Editor.CodeGenKit |
||||||
|
{ |
||||||
|
public sealed class ClassScope : CodeScope |
||||||
|
{ |
||||||
|
private readonly bool _isPartial; |
||||||
|
private readonly bool _isStatic; |
||||||
|
private readonly bool _isSealed; |
||||||
|
private readonly string _parentClassName; |
||||||
|
private readonly string _className; |
||||||
|
|
||||||
|
public bool IsStatic => _isStatic; |
||||||
|
|
||||||
|
public ClassScope(bool isPartial, bool isStatic, bool isSealed, string className, string parentClassName = "") |
||||||
|
{ |
||||||
|
_isPartial = isPartial; |
||||||
|
_isStatic = isStatic; |
||||||
|
_isSealed = isSealed; |
||||||
|
_parentClassName = parentClassName; |
||||||
|
_className = className; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenFirstLine(ICodeWriter writer) |
||||||
|
{ |
||||||
|
writer.WriteLine( |
||||||
|
$"public {(_isSealed ? "sealed " : string.Empty)}{(_isStatic ? "static " : string.Empty)}{(_isPartial ? "partial " : string.Empty)}class {_className}{(string.IsNullOrEmpty(_parentClassName) ? string.Empty : " : " + _parentClassName)}"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static partial class CodeScopeExtensions |
||||||
|
{ |
||||||
|
public static ICodeScope Class(this ICodeScope self, string className, bool isPartial, bool isStatic, |
||||||
|
bool isSealed, |
||||||
|
string parentClassName = "", Action<ClassScope> classScopeSetting = null) |
||||||
|
{ |
||||||
|
var classScope = new ClassScope(isPartial, isStatic, isSealed, className, parentClassName); |
||||||
|
classScopeSetting?.Invoke(classScope); |
||||||
|
self.Codes.Add(classScope); |
||||||
|
return self; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 87bdee7f495f44fdab681a299935d76e |
||||||
|
timeCreated: 1735993249 |
@ -0,0 +1,17 @@ |
|||||||
|
namespace Tools.Editor.CodeGenKit |
||||||
|
{ |
||||||
|
public sealed class CloseBraceCode : ICode |
||||||
|
{ |
||||||
|
private readonly bool _semicolon; |
||||||
|
|
||||||
|
public CloseBraceCode(bool semicolon) |
||||||
|
{ |
||||||
|
_semicolon = semicolon; |
||||||
|
} |
||||||
|
|
||||||
|
public void Gen(ICodeWriter writer) |
||||||
|
{ |
||||||
|
writer.WriteLine("}" + (_semicolon ? ";" : string.Empty)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 21a1d549d9fc4c5893e8b5454e43e5af |
||||||
|
timeCreated: 1735992305 |
@ -0,0 +1,26 @@ |
|||||||
|
namespace Tools.Editor.CodeGenKit |
||||||
|
{ |
||||||
|
public sealed class CustomCode : ICode |
||||||
|
{ |
||||||
|
private readonly string _content; |
||||||
|
|
||||||
|
public CustomCode(string content) |
||||||
|
{ |
||||||
|
_content = content; |
||||||
|
} |
||||||
|
|
||||||
|
public void Gen(ICodeWriter writer) |
||||||
|
{ |
||||||
|
writer.WriteLine(_content); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static partial class CodeScopeExtensions |
||||||
|
{ |
||||||
|
public static ICodeScope Custom(this ICodeScope self, string content) |
||||||
|
{ |
||||||
|
self.Codes.Add(new CustomCode(content)); |
||||||
|
return self; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: d6858c0550a54e8d9c5cf7065bf582a1 |
||||||
|
timeCreated: 1735992474 |
@ -0,0 +1,31 @@ |
|||||||
|
using System; |
||||||
|
|
||||||
|
namespace Tools.Editor.CodeGenKit |
||||||
|
{ |
||||||
|
public sealed class NameSpaceScope : CodeScope |
||||||
|
{ |
||||||
|
private readonly string _nameSpace; |
||||||
|
|
||||||
|
public NameSpaceScope(string nameSpace) |
||||||
|
{ |
||||||
|
_nameSpace = nameSpace; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void GenFirstLine(ICodeWriter writer) |
||||||
|
{ |
||||||
|
writer.WriteLine($"namespace {_nameSpace}"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static partial class CodeScopeExtensions |
||||||
|
{ |
||||||
|
public static ICodeScope NameSpace(this ICodeScope self, string nameSpace, |
||||||
|
Action<NameSpaceScope> nameSpaceSetting = null) |
||||||
|
{ |
||||||
|
var nameSpaceCode = new NameSpaceScope(nameSpace); |
||||||
|
nameSpaceSetting?.Invoke(nameSpaceCode); |
||||||
|
self.Codes.Add(nameSpaceCode); |
||||||
|
return self; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 5fe126821e724abaaaf317cceac9d41b |
||||||
|
timeCreated: 1735992680 |
@ -0,0 +1,10 @@ |
|||||||
|
namespace Tools.Editor.CodeGenKit |
||||||
|
{ |
||||||
|
public sealed class OpenBraceCode : ICode |
||||||
|
{ |
||||||
|
public void Gen(ICodeWriter writer) |
||||||
|
{ |
||||||
|
writer.WriteLine("{"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 3702874220a7472bb4f3f83980744f72 |
||||||
|
timeCreated: 1735992289 |
@ -0,0 +1,28 @@ |
|||||||
|
namespace Tools.Editor.CodeGenKit |
||||||
|
{ |
||||||
|
public sealed class UsingCode : ICode |
||||||
|
{ |
||||||
|
private readonly string _nameSpace; |
||||||
|
|
||||||
|
public UsingCode(string nameSpace) |
||||||
|
{ |
||||||
|
_nameSpace = nameSpace; |
||||||
|
} |
||||||
|
|
||||||
|
public void Gen(ICodeWriter writer) |
||||||
|
{ |
||||||
|
writer.WriteLine($"using {_nameSpace};"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public static partial class CodeScopeExtensions |
||||||
|
{ |
||||||
|
public static ICodeScope Using(this ICodeScope self, string nameSpace) |
||||||
|
{ |
||||||
|
var code = new UsingCode(nameSpace); |
||||||
|
self.Codes.Add(code); |
||||||
|
return self; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 299e6452df21426183f1622b56cfdd85 |
||||||
|
timeCreated: 1735992567 |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 541182aef19445418568c1693eda34de |
||||||
|
timeCreated: 1735992180 |
@ -0,0 +1,17 @@ |
|||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace Tools.Editor.CodeGenKit |
||||||
|
{ |
||||||
|
public sealed class RootCode : ICodeScope |
||||||
|
{ |
||||||
|
public void Gen(ICodeWriter writer) |
||||||
|
{ |
||||||
|
foreach (var code in Codes) |
||||||
|
{ |
||||||
|
code.Gen(writer); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public List<ICode> Codes { get; } = new(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 26b647313d594f05b7ca562f2b34ce56 |
||||||
|
timeCreated: 1735992153 |
@ -0,0 +1,30 @@ |
|||||||
|
using System.IO; |
||||||
|
using System.Linq; |
||||||
|
using OfficeOpenXml; |
||||||
|
using UnityEngine; |
||||||
|
|
||||||
|
namespace Tools.ExcelResolver.Editor |
||||||
|
{ |
||||||
|
public sealed partial class ExcelResolverEditorWindow |
||||||
|
{ |
||||||
|
private void ReadExcel() |
||||||
|
{ |
||||||
|
// 获取Excel文件 |
||||||
|
config.MakeSureDirectory(); |
||||||
|
var excelFiles = new DirectoryInfo(config.ExcelPathRoot).GetFiles("*.xlsx").Where(f => !f.Name.StartsWith("~$")); |
||||||
|
foreach (var excelFile in excelFiles) |
||||||
|
{ |
||||||
|
using FileStream stream = File.Open(excelFile.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); |
||||||
|
using ExcelPackage package = new ExcelPackage(stream); |
||||||
|
ExcelWorksheet worksheet = package.Workbook.Worksheets["Sheet1"]; |
||||||
|
if (null == worksheet) |
||||||
|
{ |
||||||
|
Debug.LogError($"Excel:{excelFile.Name} don't have Sheet1 !!"); |
||||||
|
continue; |
||||||
|
} |
||||||
|
var first = worksheet.Cells[1, 1]; |
||||||
|
Debug.Log(first.Value.ToString()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: c9596183fe4b47ce844563a902dabd04 |
||||||
|
timeCreated: 1735993822 |
@ -0,0 +1,31 @@ |
|||||||
|
using Tools.Editor.CodeGenKit; |
||||||
|
|
||||||
|
namespace Tools.ExcelResolver.Editor |
||||||
|
{ |
||||||
|
public sealed partial class ExcelResolverEditorWindow |
||||||
|
{ |
||||||
|
private enum TableType |
||||||
|
{ |
||||||
|
SingleKeyTable, // 单主键表 |
||||||
|
UnionMultiKeyTable, // 多主键表(联合索引) |
||||||
|
MultiKeyTable, // 多主键表(独立索引) |
||||||
|
ColumnTable, // 纵表 |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void WriteTypeCode() |
||||||
|
{ |
||||||
|
var code = new RootCode(); |
||||||
|
code.Custom("//代码使用工具生成,请勿随意修改"); |
||||||
|
code.Using("System"); |
||||||
|
code.Using("System.Collections.Generic"); |
||||||
|
code.Using("System.Linq"); |
||||||
|
|
||||||
|
code.NameSpace(config.GenerateDataClassNameSpace, cope => |
||||||
|
{ |
||||||
|
cope.Custom("[Serializable]"); |
||||||
|
// cope.Class($"") |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 4cf09c9741d243cd8c9002f7249aae06 |
||||||
|
timeCreated: 1735991897 |
@ -0,0 +1,7 @@ |
|||||||
|
namespace Tools.ExcelResolver.Editor |
||||||
|
{ |
||||||
|
public sealed partial class ExcelResolverEditorWindow |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 1751ebb7e31442b2939a16c185a1bb43 |
||||||
|
timeCreated: 1735991637 |
Loading…
Reference in new issue