Пример #1
0
        public string Evaluate(TagModel model)
        {
            ChooseItemCoreTag applicable = null;

            foreach (ITag tag in _nestedTags)
            {
                var itemTag = (ChooseItemCoreTag)tag;
                if (itemTag is Otherwise && _nestedTags.IndexOf((ITag)itemTag) != _nestedTags.Count - 1)
                {
                    throw TagException.ShouldBeLast(typeof(Otherwise)).Decorate(itemTag.Context);
                }
                if (itemTag.Applies(model))
                {
                    applicable = itemTag;
                    break;
                }
            }
            return(applicable != null?GetAsString(applicable.Body, model) : String.Empty);
        }