@@ -4,8 +4,6 @@ namespace GameFrameX.ProtoExport
44{
55 internal static class Program
66 {
7- private static IProtoGenerateHelper ProtoGenerateHelper ;
8-
97 private static int Main ( string [ ] args )
108 {
119 var launcherOptions = Parser . Default . ParseArguments < LauncherOptions > ( args ) . Value ;
@@ -21,46 +19,7 @@ private static int Main(string[] args)
2119 return 1 ;
2220 }
2321
24- if ( ! Directory . Exists ( launcherOptions . OutputPath ) )
25- {
26- Directory . CreateDirectory ( launcherOptions . OutputPath ) ;
27- }
28-
29-
30- var types = typeof ( IProtoGenerateHelper ) . Assembly . GetTypes ( ) ;
31- foreach ( var type in types )
32- {
33- var attrs = type . GetCustomAttributes ( typeof ( ModeAttribute ) , true ) ;
34- if ( attrs ? . Length > 0 && ( attrs [ 0 ] is ModeAttribute modeAttribute ) && modeAttribute . Mode == modeType )
35- {
36- ProtoGenerateHelper = ( IProtoGenerateHelper ) Activator . CreateInstance ( type ) ;
37- break ;
38- }
39- }
40-
41- var files = Directory . GetFiles ( launcherOptions . InputPath , "*.proto" , SearchOption . AllDirectories ) ;
42-
43- var messageInfoLists = new List < MessageInfoList > ( files . Length ) ;
44- foreach ( var file in files )
45- {
46- var operationCodeInfo = MessageHelper . Parse ( File . ReadAllText ( file ) , Path . GetFileNameWithoutExtension ( file ) , launcherOptions . OutputPath , launcherOptions . IsGenerateErrorCode ) ;
47- messageInfoLists . Add ( operationCodeInfo ) ;
48- switch ( modeType )
49- {
50- case ModeType . Server :
51- case ModeType . Unity :
52- ProtoGenerateHelper ? . Run ( operationCodeInfo , launcherOptions . OutputPath , launcherOptions . NamespaceName ) ;
53- break ;
54- case ModeType . TypeScript :
55- ProtoGenerateHelper ? . Run ( operationCodeInfo , launcherOptions . OutputPath , Path . GetFileNameWithoutExtension ( file ) ) ;
56- break ;
57- default :
58- throw new ArgumentOutOfRangeException ( ) ;
59- }
60- }
61-
62- ProtoGenerateHelper ? . Post ( messageInfoLists , launcherOptions . OutputPath ) ;
63-
22+ ProtoBufMessageHandler . Start ( launcherOptions , modeType ) ;
6423
6524 Console . WriteLine ( "导出成功,按任意键退出" ) ;
6625 Console . ReadKey ( ) ;
0 commit comments