public void Load(Defines defines, RemoteAgent agent) { this.Agent = agent; TopModule = defines.TopModule; foreach (var c in defines.Consts) { AddType(new DefConst(c)); } foreach (var e in defines.Enums) { AddType(new DefEnum(e)); } foreach (var b in defines.Beans) { AddType(new DefBean(b)); } foreach (var p in defines.DbTables) { AddType(new DefTable(p)); } foreach (var type in Types.Values) { type.AssemblyBase = this; } foreach (var type in Types.Values) { try { s_logger.Trace("precompile type:{0} begin", type.FullName); type.PreCompile(); s_logger.Trace("precompile type:{0} end", type.FullName); } catch (Exception) { agent.Error("precompile type:{0} error", type.FullName); throw; } } foreach (var type in Types.Values) { try { s_logger.Trace("compile type:{0} begin", type.FullName); type.Compile(); s_logger.Trace("compile type:{0} end", type.FullName); } catch (Exception) { agent.Error("compile type:{0} error", type.FullName); s_logger.Error("compile type:{0} error", type.FullName); throw; } } foreach (var type in Types.Values) { try { s_logger.Trace("post compile type:{0} begin", type.FullName); type.PostCompile(); s_logger.Trace("post compile type:{0} end", type.FullName); } catch (Exception) { agent.Error("post compile type:{0} error", type.FullName); s_logger.Error("post compile type:{0} error", type.FullName); throw; } } }
public void Load(Defines defines, RemoteAgent agent, GenArgs args) { LoadCommon(defines, agent, args); foreach (var e in defines.Enums) { AddType(new DefEnum(e)); } foreach (var b in defines.Beans) { AddType(new DefBean(b)); } foreach (var p in defines.Protos) { AddType(new DefProto(p)); } foreach (var r in defines.Rpcs) { AddType(new DefRpc(r)); } foreach (var type in Types.Values) { type.AssemblyBase = this; } foreach (var type in Types.Values) { try { s_logger.Trace("precompile type:{0} begin", type.FullName); type.PreCompile(); s_logger.Trace("precompile type:{0} end", type.FullName); } catch (Exception) { agent.Error("precompile type:{0} error", type.FullName); throw; } } foreach (var type in Types.Values) { try { s_logger.Trace("compile type:{0} begin", type.FullName); type.Compile(); s_logger.Trace("compile type:{0} end", type.FullName); } catch (Exception) { agent.Error("compile type:{0} error", type.FullName); s_logger.Error("compile type:{0} error", type.FullName); throw; } } foreach (var type in Types.Values) { try { s_logger.Trace("post compile type:{0} begin", type.FullName); type.PostCompile(); s_logger.Trace("post compile type:{0} end", type.FullName); } catch (Exception) { agent.Error("post compile type:{0} error", type.FullName); s_logger.Error("post compile type:{0} error", type.FullName); throw; } } }
public void Load(string outputService, Defines defines, RemoteAgent agent) { this.Agent = agent; SupportDatetimeType = true; TopModule = defines.TopModule; CfgTargetService = defines.Services.Find(s => s.Name == outputService); if (CfgTargetService == null) { throw new ArgumentException($"service:{outputService} not exists"); } foreach (var c in defines.Consts) { AddType(new DefConst(c)); } foreach (var e in defines.Enums) { AddType(new DefEnum(e)); } foreach (var b in defines.Beans) { AddType(new DefBean((CfgBean)b)); } foreach (var p in defines.Tables) { var table = new DefTable(p); AddType(table); AddCfgTable(table); } _cfgServices.AddRange(defines.Services); foreach (var type in Types.Values) { type.AssemblyBase = this; } foreach (var type in Types.Values) { try { s_logger.Trace("precompile type:{0} begin", type.FullName); type.PreCompile(); s_logger.Trace("precompile type:{0} end", type.FullName); } catch (Exception) { agent.Error("precompile type:{0} error", type.FullName); throw; } } foreach (var type in Types.Values) { try { s_logger.Trace("compile type:{0} begin", type.FullName); type.Compile(); s_logger.Trace("compile type:{0} end", type.FullName); } catch (Exception) { agent.Error("compile type:{0} error", type.FullName); s_logger.Error("compile type:{0} error", type.FullName); throw; } } foreach (var type in Types.Values) { try { s_logger.Trace("post compile type:{0} begin", type.FullName); type.PostCompile(); s_logger.Trace("post compile type:{0} end", type.FullName); } catch (Exception) { agent.Error("post compile type:{0} error", type.FullName); s_logger.Error("post compile type:{0} error", type.FullName); throw; } } // 丑陋. 怎么写更好? // 递归 设置DefBean及DefField 的 IsMultiRow var multiRowBeans = new HashSet <DefBean>(); for (bool anyMark = true; anyMark;) { anyMark = false; foreach (var type in this.Types.Values) { if (type is DefBean beanType && !beanType.IsMultiRow) { bool isMultiRows; if (beanType.IsNotAbstractType) { isMultiRows = beanType.HierarchyFields.Any(f => ((DefField)f).ComputeIsMultiRow()); } else { isMultiRows = beanType.HierarchyNotAbstractChildren.Any(c => ((DefBean)c).IsMultiRow); } if (isMultiRows) { beanType.IsMultiRow = true; //s_logger.Info("bean:{bean} is multi row", beanType.FullName); anyMark = true; } } } } }