SetVar() публичный Метод

public SetVar ( String Name, dynamic Value ) : void
Name String
Value dynamic
Результат void
Пример #1
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();
                }
            }
        }
Пример #2
0
		async protected Task ForeachAsync(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);
				await Iteration();
				Index++;
			}

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