private ClassMember GetMemberDeclare(ISheet sheet, int index) { IRow partRow = sheet.GetRow((int)E_DATA_ROW.PART); ICell partCell = partRow.GetCell(index); if (partCell == null) { return(null); } IRow attributeRow = sheet.GetRow((int)E_DATA_ROW.ATTRIBUTE); ICell attributeCell = attributeRow == null ? null : attributeRow.GetCell(index); IRow typeRow = sheet.GetRow((int)E_DATA_ROW.TYPE); ICell typeCell = typeRow.GetCell(index); IRow columnRow = sheet.GetRow((int)E_DATA_ROW.NAME) ?? throw new ArgumentNullException("sheet.GetRow((int) E_DATA_ROW.NAME)"); ICell columnCell = columnRow.GetCell(index); string name = columnCell.StringOrNull(); string type = typeCell.StringOrNull(); string attribute = string.Empty; if (attributeCell != null) { attribute = attributeCell.StringOrNull(); } E_PART part = (E_PART)Enum.Parse(typeof(E_PART), partCell.StringCellValue); return(ClassMember.GenClassMember(part, attribute, type, name)); }
private EnumDeclare GetEnumDeclareFromSingleSheet(ISheet sheet) { EnumDeclare ret = new EnumDeclare(); List <EnumMember> args = new List <EnumMember>(); for (int rownum = 1; rownum <= sheet.LastRowNum; ++rownum) { IRow row = sheet.GetRow(rownum); string part_value = row.GetCell((int)E_SINGLE_ENUM_COLUMN.PART).StringOrNull(); if (string.IsNullOrEmpty(part_value)) { continue; } E_PART part = (E_PART)Enum.Parse(typeof(E_PART), part_value); string attribute = row.GetCell((int)E_SINGLE_ENUM_COLUMN.ATTRIBUTE).StringOrNull(); string name = row.GetCell((int)E_SINGLE_ENUM_COLUMN.NAME).StringOrNull(); string value = row.GetCell((int)E_SINGLE_ENUM_COLUMN.VALUE).StringOrNull(); string desc = row.GetCell((int)E_SINGLE_ENUM_COLUMN.DESC).StringOrNull(); string[] attributes = null; if (!string.IsNullOrEmpty(attribute)) { attributes = attribute.Split(';').ToArray(); } args.Add(new EnumMember { name = name, value = value, desc = desc, attributes = attributes }); } ret.name = sheet.SheetName.Remove(0, ENUM_SHEET_PREFIX.Length); ret.args = args.ToArray(); return(ret); }
public static ClassMember GenClassMember(E_PART part, string attribute, string type, string name) { string[] attributes = null; if (!string.IsNullOrEmpty(attribute)) { attributes = attribute.Split(';').ToArray(); } return(new ClassMember { part = part, attributes = attributes, type = type, name = name }); }
private EnumDeclare GetEnumDeclare(ISheet sheet, int rownum) { EnumDeclare ret = new EnumDeclare(); IRow row = sheet.GetRow(rownum); ICell partCell = row.GetCell((int)E_ENUM_ROW.PART); if (partCell == null) { return(null); } ICell attributeCell = row.GetCell((int)E_ENUM_ROW.ATTRIBUTE); ICell nameCell = row.GetCell((int)E_ENUM_ROW.NAME); if (string.IsNullOrEmpty(nameCell.StringCellValue)) { return(null); } E_PART part = (E_PART)Enum.Parse(typeof(E_PART), partCell.StringCellValue); string attribute = null; if (attributeCell != null) { attribute = attributeCell.StringCellValue; } List <string> args = new List <string>(); for (int cellnum = (int)E_ENUM_ROW.NAME + 1; cellnum < this.GetColumnMax(sheet); ++cellnum) { ICell cell = row.GetCell(cellnum); if (cell == null) { break; } if (string.IsNullOrEmpty(cell.StringCellValue)) { break; } args.Add(cell.StringCellValue); } return(EnumDeclare.GenEnumDeclare(part, attribute, nameCell.StringCellValue, args.ToArray())); }
public static EnumDeclare GenEnumDeclare(E_PART part, string attribute, string name, string[] args) { string[] attributes = null; if (!string.IsNullOrEmpty(attribute)) { attributes = attribute.Split(';').ToArray(); } return(new EnumDeclare { part = part, attributes = attributes, name = name, args = EnumMember.GenEnumMembers(args) }); }