public void SetExpressions()
        {
            for (int i = 1; i <= 6; i++)
            {
                int y = i;
                P20A.SetExpr(y, () => Projects.Sum(x => x.P20A[y]));
                P20B.SetExpr(y, () => Projects.Sum(x => x.P20B[y]));
                P20C.SetExpr(y, () => Projects.Sum(x => x.P20C[y]));
                P20D.SetExpr(y, () => Projects.Sum(x => x.P20D[y]));
                P20E.SetExpr(y, () => Projects.Sum(x => x.P20E[y]));
                P20F.SetExpr(y, () => Projects.Sum(x => x.P20F[y]));
                P22A.SetExpr(y, () => Projects.Sum(x => x.P22A[y]));

                var city = DocumentManager.CurrentDocument.City;
                C8A.SetExpr(y, () => city.C8A[y]);
                C8B.SetExpr(y, () => city.C8B[y]);
                C8C_1.SetExpr(y, () => city.C8C[y] * city.C14A);
                C8D.SetExpr(y, () => city.C8D[y]);
                C7C.SetExpr(y, () => city.C7C[y]);
                C8E.SetExpr(y, () => city.C8E[y]);
            }
            P20G = new YearwiseSum(P20A, P20B, P20C, P20D, P20E, P20F);
        }
 public void SetExpressions()
 {
     C1F = new YearwiseSum(C02, 4, C1A, C1B, C1C, C1D, C1E);
     for (int i = 0; i < 3; i++)
     {
         int year = -i; // 循环变量复制后才能用于匿名函数
         C1G.SetExpr(year, () =>
         {
             return((C1A[year] - C1A[year - 1]) / C1A[year - 1]);
         });
         C1H.SetExpr(year, () => (C1B[year] - C1B[year - 1]) / C1B[year - 1]);
         C1I.SetExpr(year, () => (C1C[year] - C1C[year - 1]) / C1C[year - 1]);
     }
     C2D = new YearwiseSum(C02, 4, C2A, C2B, C2C);
     for (int i = 0; i < 3; i++)
     {
         int year = -i;
         C2C.SetExpr(year, () => C4D[year]); // mod 20120206
         C2E.SetExpr(year, () => (C2A[year] - C2A[year - 1]) / C2A[year - 1]);
         C2F.SetExpr(year, () => (C2B[year] - C2B[year - 1]) / C2B[year - 1]);
     }
     C2C.SetExpr(-3, () => C4D[-3]); // mod 20120206
     C3E = new YearwiseSum(C02, 4, C3A, C3B, C3C, C3D);
     C4D = new YearwiseSum(C02 + 10, 4, C4B, C4C);
     C6F = new YearwiseSum(C02, 4, C6A, C6B, C6C, C6D, C6E);
     for (int i = 0; i <= 3; i++)
     {
         int year = -i;
         C6A.SetExpr(year, () => C1A[year]);
         C6B.SetExpr(year, () => C1B[year]);
         C6C.SetExpr(year, () => C1C[year]);
         C6D.SetExpr(year, () => C1D[year]);
         C6E.SetExpr(year, () => C1E[year]);
     }
     for (int i = 1; i <= 10; i++)
     {
         if (i == 1)
         {
             int y = i;
             C6A.SetExpr(y, () => C6A[y - 1] + C6A[y - 1] * C1G.KnownYearsAverage);
             C6B.SetExpr(y, () => C6B[y - 1] + C6B[y - 1] * C1H.KnownYearsAverage);
             C6C.SetExpr(y, () => C6C[y - 1] + C6C[y - 1] * C1I.KnownYearsAverage);
             C6D.SetExpr(y, () => C1D.KnownYearsAverage);
             C6E.SetExpr(y, () => C1E[y - 1]);
         }
         else
         {
             int y = i;
             C6A.SetExpr(y, () => C6A[y - 1] * (1 + C9A[y] * C15A_1) * (1 + C9B[y] * C15A_2));
             C6B.SetExpr(y, () => C6B[y - 1] * (1 + C9A[y] * C15B_1) * (1 + C9B[y] * C15B_2));
             C6C.SetExpr(y, () => C6C[y - 1] * (1 + C9A[y] * C15C_1) * (1 + C9B[y] * C15C_2));
             C6D.SetExpr(y, () => C6D[y - 1] * (1 + C9A[y] * C15D_1) * (1 + C9B[y] * C15D_2));
             C6E.SetExpr(y, () => C6E[y - 1] * (1 + C9A[y] * C15E_1) * (1 + C9B[y] * C15E_2));
         }
     }
     C7D = new YearwiseSum(C02, 4, C7A, C7B, C7C);
     for (int i = 0; i <= 3; i++)
     {
         int year = -i;
         C7A.SetExpr(year, () => C2A[year]);
         C7B.SetExpr(year, () => C2B[year]);
         C7C.SetExpr(year, () => C2C[year]);
     }
     for (int i = 1; i <= 10; i++)
     {
         if (i == 1)
         {
             int y = i;
             C7A.SetExpr(y, () => C7A[y - 1] + C7A[y - 1] * C2E.KnownYearsAverage);
             C7B.SetExpr(y, () => C7B[y - 1] + C7B[y - 1] * C2F.KnownYearsAverage);
             C7C.SetExpr(y, () => C4D[y]);
         }
         else
         {
             int y = i;
             C7A.SetExpr(y, () => C7A[y - 1] * (1 + C9A[y] * C16A_1) * (1 + C9B[y] * C16A_2));
             C7B.SetExpr(y, () => C7B[y - 1] * (1 + C9A[y] * C16B_1) * (1 + C9B[y] * C16B_2));
             C7C.SetExpr(y, () => C4D[y]);
         }
     }
     for (int i = -3; i <= 10; i++)
     {
         int year = i;
         C8A.SetExpr(year, () =>
         {
             if (year > 0)
             {
                 return(C6F[year] - C6D[year]);
             }
             else
             {
                 return(C6F[year] - C6C[year]);
             }
         });
         C8B.SetExpr(year, () => C7B[year] + C7C[year]);
         C8C.SetExpr(year, () => C8A[year] - C8B[year]);
         C8D.SetExpr(year, () => C8C[year] * C14A);
         C8E.SetExpr(year, () => C8C[year] * C14B);
     }
 }