/// <summary> /// Создать класс который возвращает список шаблонов, для того чтобы потом их положить в базу /// </summary> /// <param name="opts"></param> /// <returns></returns> public static GenerateClassBaseModel GetInitDataClass(TemplateCodeInitDataOptions opts) { var cl = new GenerateClassBaseModel { ClassName = $"{opts.TemplateSchemaName}InitData", IsStatic = false, Summary = opts.Summary, NameSpace = "Ecc.Model.InitData.Templates", Usings = new HashSet <string> { "Cmn.Constants.Ecc", "Cmn.Enums.Ecc", "Ecc.Model.OtherModels", "Ecc.Model.Resources", "System.Collections.Generic" } }; cl.Properties.Add(new GenerateStaticGetListOfDataMethod { Description = "Получить модели для создания шаблонов", EnumeratedElementClassName = "CreateMessageTemplate", PropertyName = "GetTemplates", EnumeratedElements = opts.Data.Select(x => GetPropertyDictionary(x, opts)).ToList() }); return(cl); }
private static Dictionary <string, string> GetPropertyDictionary(TemplateBlockJustTextModel x, TemplateCodeInitDataOptions opts) { var dict = new Dictionary <string, string> { ["Name"] = $"{opts.ResourcesClassName}.{TemplatesBlockExtensions.ToTemplateNameResourceKey(x.TriggerName)}", ["InteractionType"] = PropertyToGeneratedString.ToString(opts.InteractionType), ["MessageType"] = "MessageType.NotSet", ["Header"] = $"{opts.ResourcesClassName}.{TemplatesBlockExtensions.ToTemplateHeaderResourceKey(x.TriggerName)}", ["Body"] = $"{opts.ResourcesClassName}.{TemplatesBlockExtensions.ToTemplateBodyResourceKey(x.TriggerName)}", ["Uid"] = GetTriggerUidProperty(opts.TemplateSchemaName, x.TriggerName) }; if (x is TemplateBlock t) { dict[nameof(TemplateBlock.AnyTimeAllowed)] = PropertyToGeneratedString.ToString(t.AnyTimeAllowed); dict[nameof(TemplateBlock.AllowedFromHour)] = PropertyToGeneratedString.ToString(t.AllowedFromHour); dict[nameof(TemplateBlock.AllowedToHour)] = PropertyToGeneratedString.ToString(t.AllowedToHour); } return(dict); }