コード例 #1
0
 public FormulaSheetParam(FormulaSheetParam sheetParam)
 {
     this.Name = sheetParam.Name;
     this.SheetIndex = sheetParam.SheetIndex;
     this.Sheet = sheetParam.Sheet;
     this.Type = sheetParam.Type;
 }
コード例 #2
0
        private IDictionary<string, FormulaSheetParam> GetSheetParams(XElement formulaElement, IDictionary<string, FormulaSheetParam> templateSheetParams, XNamespace ns)
        {
            var sheetParams = new Dictionary<string, FormulaSheetParam>();
            if (templateSheetParams != null && templateSheetParams.Keys.Count > 0)
            {
                foreach (var key in templateSheetParams.Keys)
                {
                    sheetParams.Add(key, new FormulaSheetParam(templateSheetParams[key]));
                }
            }

            var formulaParamsElement = formulaElement.GetChild("Params", ns);
            if (formulaParamsElement != null)
            {
                Func<XElement, bool> filterExp = (e => { return e.GetEnumValue<FormulaParamType>("Type") == FormulaParamType.Sheet; });

                var sheetParamElements = formulaParamsElement.GetDescendants("Param", ns, filterExp);

                foreach (var paramElement in sheetParamElements)
                {
                    var sheetParam = new FormulaSheetParam()
                    {
                        Name = paramElement.GetStringValue("Name"),
                        Type = FormulaParamType.Sheet,
                        SheetIndex = paramElement.GetValue<Int32>("Index")
                    };

                    var sheetElement = paramElement.Document.Root.GetChild("KPISheets", ns).GetDescendants("Sheet", ns).SingleOrDefault(e => e.GetValue<Int32>("Index") == sheetParam.SheetIndex);

                    if (sheetElement == null)
                        throw new NullReferenceException(string.Format("Coluldn't find any KPI Sheet which Index is {0}", sheetParam.SheetIndex));

                    sheetParam.Sheet = sheetElement.GetStringValue("Name");

                    if (!sheetParams.ContainsKey(sheetParam.Name))
                    {
                        sheetParams.Add(sheetParam.Name, sheetParam);
                    }
                    else
                    {
                        sheetParams[sheetParam.Name] = sheetParam;
                    }
                }
            }

            return sheetParams;
        }