static void Main(string[] args) { // Console.WriteLine($"Hello {subject}!"); LoggerInit.Init(); var _logger = Logger.CreateLogger <Program>(); Parser.Default.ParseArguments <Options>(args) .WithParsed <Options>(o => { try { RunOptions = o; _logger.LogInformation("*** App Starting IsModel={1}".CallerInfo(), o.IsModel); //_logger.LogInformation("*** App Starting {@Args}".CallerInfo(), args.Aggregate((s1, s2) => //{ // return s1 + " " + s2; //})); var ncs = o.ProtoFileName.ToNameCs(); string reflectionClass = ncs + "Reflection"; //Type reflection = typeof(Proto.Config.Connection.ConnMssqlReflection).Assembly.GetType(destNS + "." + reflectionClass); var types = typeof(Proto.Doc.ProtoDocReflection).Assembly.GetTypes(); Type reflection = null; foreach (var t in types) { if (t.Name == reflectionClass) { reflection = t; break; } } var protoNS = reflection.FullName.Substring(0, reflection.FullName.LastIndexOf('.')); //Type reflection = typeof(Proto.Config.Connection.ConnMssqlReflection).Assembly.GetType(reflectionClass); var descr = reflection.GetProperty("Descriptor", BindingFlags.Public | BindingFlags.Static); object value = descr.GetValue(null, null); FileDescriptor typedValue = (FileDescriptor)value; Dictionary <string, List <MessageDescriptor> > dicParents = new Dictionary <string, List <MessageDescriptor> >(); List <MessageDescriptor> messages = CollectMessages(typedValue, dicParents); //string path = "../../../../doc/" + protofilename + ".json"; string path = o.JsonDocFolder + o.ProtoFileName + ".json"; ProtoDoc.CreateDoc(path); string res = null; if (o.IsModel) { NameSpace ns = new NameSpace(typedValue, messages, dicParents, o.Namespace, protoNS, o.BaseclassDefault); res = ns.TransformText(); } else if (o.IsInterface) { ModelInterfaces ns = new ModelInterfaces(typedValue, messages, dicParents, o.Namespace, protoNS); res = ns.TransformText(); } else { throw new ArgumentException("Expected 'model' or 'interface'"); } string filedest = o.OutputFile; if (!File.Exists(filedest)) { File.CreateText(filedest); } using (var fs = File.Open(filedest, FileMode.OpenOrCreate | FileMode.Truncate, FileAccess.Write, FileShare.Write)) { var bytes = Encoding.UTF8.GetBytes(res); fs.Write(bytes, 0, bytes.Count()); } } catch (Exception) { throw; } finally { //System.Diagnostics.Trace.WriteLine("##### GenFromProto current dir: " + Directory.GetCurrentDirectory()); } }); }