Get() public static method

Gets a UrlLinkFrame object of a specified type from a specified tag, optionally creating and adding one with a specified encoding if none is found.
To create a frame without having to specify the encoding, use Get(Tag,ByteVector,bool).
/// or is /// . /// /// is not exactly four bytes long. ///
public static Get ( Tag tag, ByteVector ident, bool create ) : UrlLinkFrame
tag Tag /// A object to search for the specified /// tag in. ///
ident ByteVector /// A object containing the frame /// identifer to search for. ///
create bool /// A value specifying whether or not to /// create a new frame if an existing frame was not found. ///
return UrlLinkFrame
Exemplo n.º 1
0
        public string GetTextAsString(ByteVector ident)
        {
            Frame frame;

            if (ident[0] == 'W')
            {
                frame = UrlLinkFrame.Get(this, ident, false);
            }
            else
            {
                frame = TextInformationFrame.Get(this, ident, false);
            }
            string result = frame == null?null:frame.ToString();

            return(string.IsNullOrEmpty(result)?null:result);
        }
Exemplo n.º 2
0
        public void SetTextFrame(ByteVector ident, params string[] text)
        {
            if (ident == null)
            {
                throw new ArgumentNullException("ident");
            }
            if (ident.Count != 4)
            {
                throw new ArgumentException("Identifier must be four bytes long.", "ident");
            }
            bool empty = true;

            if (text != null)
            {
                for (int i = 0; empty && i < text.Length; i++)
                {
                    if (!string.IsNullOrEmpty(text[i]))
                    {
                        empty = false;
                    }
                }
            }
            if (empty)
            {
                RemoveFrames(ident);
                return;
            }
            if (ident[0] == 'W')
            {
                UrlLinkFrame urlFrame = UrlLinkFrame.Get(this, ident, true);
                urlFrame.Text         = text;
                urlFrame.TextEncoding = DefaultEncoding;
                return;
            }
            TextInformationFrame frame = TextInformationFrame.Get(this, ident, true);

            frame.Text         = text;
            frame.TextEncoding = DefaultEncoding;
        }