| 1234567891011121314151617181920212223242526 |
- using System;
- using CommandLine;
- namespace Model
- {
- [ObjectEvent]
- public class OptionComponentEvent : ObjectEvent<OptionComponent>, IAwake<string[]>
- {
- public void Awake(string[] args)
- {
- this.Get().Awake(args);
- }
- }
-
- public class OptionComponent : Component
- {
- public Options Options { get; set; }
- public void Awake(string[] args)
- {
- Parser.Default.ParseArguments<Options>(args)
- .WithNotParsed(error => throw new Exception($"命令行格式错误!"))
- .WithParsed(options => { Options = options; });
- }
- }
- }
|