Ejemplo n.º 1
0
        //public ConfigRow[] rows
        //{
        //    get { return this._rowList.ToArray(); }
        //}

        //public List<ConfigRow> RowList
        //{
        //    get { return this._rowList; }
        //}

        //根据条件值返回行
        public ConfigRow getRow(System.Enum key, string value)
        {
            int count = reader.getRowCount();

            for (int index = 0; index < count; index++)
            {
                ConfigRow row = reader.getRow(index);
                if (row == null)
                {
                    continue;
                }
                string temp = "";
                if (row.getStringValue(key, out temp))
                {
                    if (temp == value)
                    {
                        return(row);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        static private string getConfigValue(System.Reflection.FieldInfo fieldInfo, ConfigTable table, ConfigRow configRow)
        {
            string[] columnNames = getDescriptionNames(fieldInfo);

            if (columnNames != null)
            {
                string configValue = string.Empty;

                int columnNamesLength = columnNames.Length;
                for (int i = 0; i < columnNamesLength; i++)
                {
                    if (i > 0)
                    {
                        configValue += SEPARATOR;
                    }

                    string columnName  = columnNames[i];
                    int    columnIndex = 0;
                    string cellValue   = "";

                    ListAttribute[] attributes = (ListAttribute[])fieldInfo.GetCustomAttributes(typeof(ListAttribute), false);
                    if (attributes.Length > 0)
                    {
                        //如果是多欄位要合成list 就執行這邊
                        string columnNameTemp = columnName + 0;
                        columnIndex = table.getColumnIndex(columnNameTemp);
                        if (columnIndex != -1)
                        {
                            cellValue = configRow.getStringValue(columnIndex);
                            if (!string.IsNullOrEmpty(cellValue))
                            {
                                configValue = cellValue;
                            }
                        }

                        for (int j = 1; j < 100; j++)
                        {
                            columnNameTemp = columnName + j;
                            columnIndex    = table.getColumnIndex(columnNameTemp);
                            if (columnIndex != -1)
                            {
                                cellValue = configRow.getStringValue(columnIndex);
                                if (!string.IsNullOrEmpty(cellValue))
                                {
                                    configValue = configValue + ":" + cellValue;
                                }
                            }
                        }
                    }
                    else
                    {
                        columnIndex  = table.getColumnIndex(columnName);
                        cellValue    = configRow.getStringValue(columnIndex);
                        configValue += cellValue;
                    }
                }

                return(configValue);
            }

            return(null);
        }