public static bool TryCreate(string text, out MameInfo mameInfo) { mameInfo = new MameInfo(); int itemStart = 0; int itemEnd = text.IndexOf('\n'); if(itemEnd < 0) return false; mameInfo.Title = text.Substring(itemStart, itemEnd).Trim(); while (true) { itemEnd++; if (itemEnd >= text.Length) break; itemStart = itemEnd; itemEnd = text.IndexOf('\n', itemStart); if (itemEnd < 0) return false; string info = text.Substring(itemStart, itemEnd - itemStart); int tagEnd = info.IndexOf(':'); if (tagEnd < 0) continue; string tag = info.Remove(tagEnd).Trim(); string val = info.Substring(tagEnd + 1).Trim(); if (tag == "Genre") mameInfo.Genre = val; else if (tag == "Release Year") mameInfo.Year = val; else if (tag == "Developer") mameInfo.Developer = val; else if (tag == "Game Filename") { mameInfo.Filename = val; itemEnd++; if (itemEnd < text.Length) { int descriptionEnd = text.IndexOf("\n*#*#*#*", itemEnd); if (descriptionEnd < 0) descriptionEnd = text.Length; mameInfo.Description = text.Substring(itemEnd, descriptionEnd - itemEnd).Trim(); } break; } } return mameInfo.Filename != null; }
ScraperResult createResult(MameInfo mameInfo, ScraperSearchParams searchParams) { return new ScraperResult(mameInfo.Filename, mameInfo.Title, "Arcade", mameInfo.Year, this, searchParams); }