public string Resolve(ResolveContext context) { object executeResult = null; if (!string.IsNullOrWhiteSpace(this.RefId)) { if (!context.InsqlDescriptor.Sections.ContainsKey(this.RefId)) { throw new ArgumentException($"mapper section id : {this.RefId} not found !"); } IInsqlSection sectionDescriptor = context.InsqlDescriptor.Sections[this.RefId]; executeResult = sectionDescriptor.Resolve(new ResolveContext { ServiceProvider = context.ServiceProvider, InsqlDescriptor = context.InsqlDescriptor, SectionDescriptor = sectionDescriptor, Param = context.Param }); } else if (!string.IsNullOrWhiteSpace(this.Value)) { var codeExecuter = context.ServiceProvider.GetRequiredService <IInsqlCodeResolver>(); executeResult = codeExecuter.Resolve(typeof(object), this.Value, context.Param); } //给上下文设置参数 context.Param[this.Name] = executeResult; //返回空内容 return(string.Empty); }
public string Resolve(ResolveContext context) { if (!context.InsqlDescriptor.Sections.ContainsKey(this.RefId)) { throw new ArgumentException($"mapper section id : {this.RefId} not found !"); } IInsqlSection sectionDescriptor = context.InsqlDescriptor.Sections[this.RefId]; return((string)sectionDescriptor.Resolve(new ResolveContext { ServiceProvider = context.ServiceProvider, InsqlDescriptor = context.InsqlDescriptor, SectionDescriptor = sectionDescriptor, Param = context.Param })); }
public string Resolve(ResolveContext context) { bool isTest = false; if (!string.IsNullOrWhiteSpace(this.RefId)) { if (!context.InsqlDescriptor.Sections.ContainsKey(this.RefId)) { throw new ArgumentException($"mapper section id : {this.RefId} not found !"); } IInsqlSection sectionDescriptor = context.InsqlDescriptor.Sections[this.RefId]; isTest = (bool)sectionDescriptor.Resolve(new ResolveContext { ServiceProvider = context.ServiceProvider, InsqlDescriptor = context.InsqlDescriptor, SectionDescriptor = sectionDescriptor, Param = context.Param }); } else if (!string.IsNullOrWhiteSpace(this.Test)) { var codeExecuter = context.ServiceProvider.GetRequiredService <IInsqlCodeResolver>(); isTest = (bool)codeExecuter.Resolve(typeof(bool), this.Test, context.Param); } if (!isTest) { return(string.Empty); } //parse var childrenResult = this.Children.Select(children => { return(children.Resolve(context)); }); return(string.Join(" ", childrenResult).Trim()); }