Пример #1
0
 public TemplateFilter(string name, string argument)
 {
     Name = name;
     if (argument != null)
         Argument = new TemplateVar (argument);
     else
         Argument = null;
 }
Пример #2
0
        internal object this[Scope scope, TemplateVar variable, List<TemplateFilter> filters]
        {
            get {
                object val = null;
                if (variable != null && variable.StrValue != null)
                {
                    if (variable.IsLiteralString)
                        val = variable.StrValue;
                    else
                    {
                        string varStr = variable.StrValue;
                        if (!string.IsNullOrWhiteSpace (varStr))
                        {
                            if (!GetOverride (scope, varStr, out val))
                            {
                                string[] varSplit = varStr.Split ('.');
                                if (GetOverride (scope, varSplit [0], out val))
                                {
                                    if (val != null && varSplit.Length > 1)
                                        val = ReadSubProperty (val, varSplit, 1);
                                } else
                                {
                                    int i;
                                    if (int.TryParse (variable.StrValue, out i))
                                        val = i;
                                    else
                                    {
                                        double d;
                                        if (double.TryParse (variable.StrValue, out d))
                                            val = d;
                                    }
                                }
                            }
                        }
                    }
                }

                if (filters != null && filters.Count > 0)
                {
                    int filtersCount = filters.Count;
                    KeyValuePair<string, object>[] resolvedFilters = new KeyValuePair<string, object>[filtersCount];
                    for (int i = 0; i < filtersCount; i++)
                    {
                        TemplateFilter currFilter = filters [i];
                        resolvedFilters [i] = new KeyValuePair<string, object> (currFilter.Name, this [scope, currFilter.Argument, null]);
                    }

                    return FilterManager.Filter (val, resolvedFilters);
                } else
                    return val;
            }
        }
Пример #3
0
 public object this[TemplateVar variable, List<TemplateFilter> filters]
 {
     get
     {
         return Context[_currentScope, variable, filters];
     }
 }
 public TemplateVarFiltered(string varValue, List<TemplateFilter> filters)
 {
     Variable = new TemplateVar(varValue);
     Filters = filters;
 }