Esempio n. 1
0
        protected object GetValueForConfig(MultiColumnPropertySourceConfiguration config, TReader tableReader)
        {
            if (config == null)
            {
                return(null);
            }
            string rawValue = null;
            var    list     = new List <string>();

            if (config.ColumnNames != null)
            {
                for (var index = 0; index < config.ColumnNames.Length; index++)
                {
                    var configColumnName = config.ColumnNames[index];
                    rawValue = GetValueByColumnName(tableReader, configColumnName);
                    list.Insert(index, rawValue ?? "");
                }
            }
            if (config.ColumnIndices != null)
            {
                for (var index = 0; index < config.ColumnIndices.Length; index++)
                {
                    if (list[index] == null)
                    {
                        var columnIndex = config.ColumnIndices[index];
                        if (columnIndex.HasValue)
                        {
                            rawValue    = GetValueByColumnIndex(tableReader, columnIndex.Value);
                            list[index] = rawValue;
                        }
                        else
                        {
                            throw new ArgumentException(
                                      "No column index given although name couldn't be used as index or index is prefered",
                                      "ColumnIndex");
                        }
                    }
                }
            }
            rawValue = string.Format(config.FormatString, list.Cast <object>().ToArray());
            var parser = config.ResolveParser(Context);

            return(parser.Parse(rawValue));
        }
Esempio n. 2
0
 protected bool Equals(MultiColumnPropertySourceConfiguration other)
 {
     return(base.Equals(other) && Equals(ColumnNames, other.ColumnNames) && Equals(ColumnIndices, other.ColumnIndices) && string.Equals(FormatString, other.FormatString));
 }