FunFormatStr.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using IwbZero.Expr;
  2. namespace IwbZero.ExprFunctions.Functions
  3. {
  4. /// <summary>
  5. /// Format字符串
  6. /// </summary>
  7. public class FunFormatStr:IIwbFunction
  8. {
  9. public string Invoke(ExprObject exprObj)
  10. {
  11. string text = "";
  12. ExprObject child = exprObj.GetChild(0);
  13. if (child != null)
  14. {
  15. text = child.Expr;
  16. if (exprObj.ChildCount > 1)
  17. {
  18. object[] array = new object[exprObj.ChildCount / 2];
  19. for (int i = 2; i < exprObj.ChildCount; i++)
  20. {
  21. if (i % 2 == 0)
  22. {
  23. int num = i / 2 - 1;
  24. array[num] = exprObj.GetChild(i).Expr;
  25. }
  26. //int num = i / 2 - 1;
  27. //if ((num + 1) * 2 == i)
  28. //{
  29. // array[num] = exprObj.GetChild(i).Expr;
  30. //}
  31. }
  32. text = string.Format(text, array);
  33. }
  34. }
  35. return text;
  36. }
  37. }
  38. }