public static UserUrlLinkFrame Get(Tag tag, string description, StringType type, bool create) { if (tag == null) { throw new ArgumentNullException("tag"); } if (description == null) { throw new ArgumentNullException("description"); } if (description.Length == 0) { throw new ArgumentException("Description must not be empty.", "description"); } foreach (UserUrlLinkFrame frame in tag.GetFrames <UserUrlLinkFrame>(FrameType.WXXX)) { if (description.Equals(frame.Description)) { return(frame); } } if (!create) { return(null); } UserUrlLinkFrame new_frame = new UserUrlLinkFrame(description, type); tag.AddFrame(new_frame); return(new_frame); }
/// <summary> /// Gets a specified user text frame from the specified tag, /// optionally creating it if it does not exist. /// </summary> /// <param name="tag"> /// A <see cref="Tag" /> object to search in. /// </param> /// <param name="description"> /// A <see cref="string" /> specifying the description to /// match. /// </param> /// <param name="type"> /// A <see cref="StringType" /> specifying the encoding to /// use if creating a new frame. /// </param> /// <param name="create"> /// A <see cref="bool" /> specifying whether or not to create /// and add a new frame to the tag if a match is not found. /// </param> /// <returns> /// A <see cref="UserUrlLinkFrame" /> object /// containing the matching frame, or <see langword="null" /> /// if a match wasn't found and <paramref name="create" /> is /// <see langword="false" />. /// </returns> public static UserUrlLinkFrame Get(Tag tag, string description, StringType type, bool create) { if (tag == null) throw new ArgumentNullException("tag"); if (description == null) throw new ArgumentNullException("description"); if (description.Length == 0) throw new ArgumentException( "Description must not be empty.", "description"); foreach (UserUrlLinkFrame frame in tag.GetFrames<UserUrlLinkFrame>( FrameType.WXXX)) if (description.Equals(frame.Description)) return frame; if (!create) return null; UserUrlLinkFrame new_frame = new UserUrlLinkFrame(description, type); tag.AddFrame(new_frame); return new_frame; }