/// <summary> /// Initializes a new instance of the <see cref="SpriteCategorization"/> class. /// </summary> /// <param name="category">The category.</param> /// <param name="title">The title.</param> /// <exception cref="ArgumentNullException"><paramref name="category" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="title" /> is <c>null</c>.</exception> public SpriteCategorization(SpriteCategory category, SpriteTitle title) { if (category == null) { throw new ArgumentNullException("category"); } if (title == null) { throw new ArgumentNullException("title"); } _category = category; _title = title; }
/// <summary> /// Splits apart the category and title from a single string. /// </summary> /// <param name="categoryAndTitle">The concatenated category and title.</param> /// <param name="category">The resulting category</param>. /// <param name="title">The resulting title.</param> /// <exception cref="ArgumentNullException"><paramref name="categoryAndTitle"/> is null or empty.</exception> /// <exception cref="ArgumentException"><paramref name="categoryAndTitle"/> is not property formatted.</exception> public static void SplitCategoryAndTitle(string categoryAndTitle, out SpriteCategory category, out SpriteTitle title) { if (string.IsNullOrEmpty(categoryAndTitle)) { throw new ArgumentNullException("categoryAndTitle"); } categoryAndTitle = categoryAndTitle.Replace("\\", Delimiter).Replace("/", Delimiter); var lastSep = categoryAndTitle.LastIndexOf(Delimiter, StringComparison.Ordinal); if (lastSep == -1) { throw new ArgumentException("No delimiters found.", "categoryAndTitle"); } // Split at the last separator var categoryStr = categoryAndTitle.Substring(0, lastSep); var titleStr = categoryAndTitle.Substring(lastSep + 1); category = new SpriteCategory(categoryStr); title = new SpriteTitle(titleStr); }