using System.Collections.Generic; using System.Linq; using xAiService.Models.Dtos; using xCommons.Extensions; namespace xAiService.Extensions { public static class PromptExtensions { /// /// Get Template Params Filled Prompt ... /// /// /// /// public static string GetMessage( this XPromptDto source, IDictionary @params = null ) { // var result = string.Empty; // if (!source.IsNullOrDefault() && !source.Prompt.IsNullOrEmpty() ) { result = source.Prompt; } // // Check Params Conditions ... if (!source.Params.IsNullOrDefault() && source.Params.HasChild() && !@params.IsNullOrDefault() && @params.HasChild() ) { // // Select Params ... var existsParams = source.Params .Where(p => @params.Any(pr => pr.Key == p.Name)) .Distinct() .ToList(); // // Replace Selected Params ... existsParams .ForEach(pk => { result = result.Replace(pk.Param, @params[pk.Name]); }); } // return result; } } }