public static string ResolveName(this Item item, ClilocLNG lng) { if (item == null) { return(String.Empty); } var label = item.GetOPLHeader(lng); if (!String.IsNullOrEmpty(label)) { label = label.Replace("\t", " ").Replace("\u0009", " ").Replace("<br>", "\n").Replace("<BR>", "\n").Trim(); } if (!String.IsNullOrEmpty(label)) { label = label.StripHtml(false); label = label.Trim(); int idx; if ((idx = label.IndexOf('\n')) >= 0) { if (idx > 0) { label = label.Substring(0, idx); } else { label = label.TrimStart('\n'); } } label = label.Trim(); if ((idx = label.IndexOf(' ')) >= 0) { if (idx > 0) { int amount; if (Int32.TryParse(label.Substring(0, idx), NumberStyles.Number, CultureInfo.InvariantCulture, out amount)) { label = label.Substring(idx + 1); } } else { label = label.TrimStart(' '); } } label = label.Trim(); } if (String.IsNullOrWhiteSpace(label) && item.Name != null) { label = item.Name; } if (String.IsNullOrWhiteSpace(label) && item.DefaultName != null) { label = item.DefaultName; } if (String.IsNullOrWhiteSpace(label) && item.LabelNumber > 0) { label = lng.GetString(item.LabelNumber); } if (String.IsNullOrWhiteSpace(label) && TileData.ItemTable.InBounds(item.ItemID)) { label = TileData.ItemTable[item.ItemID].Name; } if (String.IsNullOrWhiteSpace(label)) { label = item.GetType().Name.SpaceWords(); } if (!String.IsNullOrEmpty(label)) { label = label.StripExcessWhiteSpace().Trim(); } return(label); }