Пример #1
0
        public IEnumerable <StringResourceModel> GetResources()
        {
            return(new List <StringResourceModel>
            {
                //Тело сообщения засунутое в ресурс по ключу
                new StringResourceModel
                {
                    Name = TemplatesBlockExtensions.ToTemplateBodyResourceKey(TriggerName),
                    Value = TemplateBody,
                    Description = TemplateBodyTranslation
                },

                //Заголовок сообщения засунутое в ресурс по ключу
                new StringResourceModel
                {
                    Name = TemplatesBlockExtensions.ToTemplateHeaderResourceKey(TriggerName),
                    Value = Header,
                    Description = HeaderTranslation
                },

                //название шаблона засунутое в ресурс по ключу
                new StringResourceModel
                {
                    Name = TemplatesBlockExtensions.ToTemplateNameResourceKey(TriggerName),
                    Value = TriggerName,
                    Description = $"Название шаблона {TriggerName}"
                }
            });
        }
        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);
        }