Пример #1
0
 public void addParameter(string name, Parameter param)
 {
     if (param.isDimension())
     {
         dimensions.Add(name, param);
     } else if (param.isDimensionDefault())
     {
         dimensionDefaults.Add(name, param);
     }
     else if(param.isDimensionType())
     {
         dimensionTypes.Add(name, param);
     } else if (param.isDimensionAggregation())
     {
         dimensionAggregations.Add(name, param);
     }
     else
     {
         parameters.Add(name, param);
     }
 }
Пример #2
0
        public void parse(Object parameters)
        {
            if (parameters is Object[])
            {
                //Utils.log("Object[]");
                Object[] param_casted = (Object[]) parameters;
                int param_d1 = param_casted.Length;
                for (int i = 0; i < param_d1; i++)
                {
                    if (param_casted[i] == null || param_casted[i] is ExcelEmpty || param_casted[i] is ExcelMissing)
                    {
                        continue;
                    }
                    parse(param_casted[i]);
                }
            }
            else if (parameters is Object[,])
            {
                //Utils.log("Object[,]");
                Object[,] param_casted = (Object[,])parameters;
                int param_d1 = param_casted.GetLength(0);
                int param_d2 = param_casted.GetLength(1);
                for (int i = 0; i < param_d1; i++)
                {
                    for (int j = 0; j < param_d2; j++)
                    {
                        if (param_casted[i, j] == null || param_casted[i, j] is ExcelEmpty || param_casted[i, j] is ExcelMissing)
                        {
                            continue;
                        }
                        parse(param_casted[i, j]);
                    }
                }
            }
            else if (parameters is ExcelReference)
            {
                //Utils.log("ExcelReference");
                ExcelReference reference = (ExcelReference)parameters;
                List<ExcelReference> list = reference.InnerReferences;
                if (reference.GetValue() is ExcelError && list != null && list.ToArray().Length > 0)
                {
                    foreach (ExcelReference refer in list)
                    {
                        Object val = refer.GetValue();
                        parse(val);
                    }
                }
                else
                {
                    parse(reference.GetValue());
                }
            }
            else if (parameters is string)
            {
                string paramStr = Convert.ToString(parameters);

                string[] paramTokenz = paramStr.Split('&');

                if (paramTokenz.Length > 1)
                {
                    foreach (string param in paramTokenz)
                    {
                        parse(param);
                    }
                }
                else
                {
                    string[] tokenz = paramStr.Split('=');
                    string errormsg = "Invalid Parameter '" + paramStr + "'. Accepted format: 'parameter=value'.";
                    if (tokenz.Length != 2)
                    {
                        throw new ArgumentException(errormsg, "parameters");
                    }
                    string param_Key = Convert.ToString(tokenz[0]);
                    string param_Value = Convert.ToString(tokenz[1]);
                    Parameter param = getParameter(param_Key);
                    if (param != null)
                    {
                        param.addValue(param_Value);
                    }
                    else
                    {
                        param = new Parameter(param_Key, param_Value);
                        addParameter(param_Key, param);
                    }
                }
            }
            else if (parameters == null || parameters is ExcelEmpty || parameters is ExcelMissing)
            {
                ; // skip
            }
            else
            {
                throw new ArgumentException("Invalid Parameter value '" + Convert.ToString(parameters) + "' in 'parameters'.", "parameters");
            }
        }
Пример #3
0
        private string getParamValue(Parameter param)
        {
            if(param == null || param.size() == 0)
            {
                return null;
            }

            if(param.size() > 1)
            {
                throw new ArgumentException("Currently, only one value per parameter allowed: " + param.ToString(), param.getName());
            }
            return param.getValue(0);
        }