Class to perform operations on dynamic types. Without worrying about exceptions or errors.
Пример #1
0
 public dynamic AutoFilter(dynamic Value)
 {
     if (Value is RawWrapper || !Autoescape)
     {
         return(Value);
     }
     return(HtmlUtils.EscapeHtmlCharacters(DynamicUtils.ConvertToString(Value)));
 }
Пример #2
0
        public dynamic CallFilter(string FilterName, params dynamic[] Params)
        {
            Tuple <Type, string> Info;

            if (Filters.TryGetValue(FilterName, out Info))
            {
                return(DynamicUtils.Call(Info.Item1, Info.Item2, Params));
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        protected void Foreach(TemplateContext Context, String VarName, dynamic Expression, EmptyDelegate Iteration, EmptyDelegate Else = null)
        {
            int Index = 0;

            foreach (var Item in DynamicUtils.ConvertToIEnumerable(Expression))
            {
                Context.SetVar("loop", new Dictionary <String, dynamic> {
                    { "index", Index + 1 },
                    { "index0", Index },
                });
                Context.SetVar(VarName, Item);
                Iteration();
                Index++;
            }

            if (Index == 0)
            {
                if (Else != null)
                {
                    Else();
                }
            }
        }