Beispiel #1
0
        private static string HandleUserField(Dictionary <string, string> input, string key, TemplateType type, Card card)
        {
            string fieldName = GetFieldName(key);

            if (!input.TryGetValue(fieldName, out var fieldContent))
            {
                LogTo.Error("Failed to HandleUnknownField");
                return(string.Empty);
            }

            var split = key.Split(':');

            if (split.Length > 1)
            {
                // Has filters
                var filters = split
                              .Skip(1) // Skip the fieldName
                              .Reverse()
                              .ToList();

                if (type == TemplateType.Question)
                {
                    fieldContent = FilterHandler.ApplyQuestionFieldFilters(filters, fieldContent, card);
                }

                else
                {
                    fieldContent = FilterHandler.ApplyAnswerFieldFilters(filters, fieldContent, card);
                }
            }

            return(fieldContent);
        }
Beispiel #2
0
        private static string HandleSpecialFieldQuestion(Func <Card, string> specialFieldFunc, string key, Card card)
        {
            var split     = key.Split(':');
            var fieldName = split.Last();

            string specialContent = specialFieldFunc(card);

            if (split.Length > 1)
            {
                // Has filters
                var filters = split
                              .Skip(1) // Skip the field name
                              .Reverse()
                              .ToList();

                specialContent = FilterHandler.ApplyQuestionFieldFilters(filters, specialContent, card);
            }

            return(specialContent);
        }