Example #1
0
        /// <summary>
        /// Converts the string representation of a <see cref="AttachmentIdentifier"/> to its <see cref="AttachmentIdentifier"/> equivalent.
        /// A return value indicates whether the conversion is succeeded or failed.
        /// </summary>
        /// <param name="s">The <see cref="string"/> to convert.</param>
        /// <param name="identifier">The converted <see cref="string"/>.</param>
        /// <returns><see langword="true"/> if <see cref="string"/> was converted successfully; otherwise, <see langword="false"/>.</returns>
        public static bool TryParse(string s, out AttachmentIdentifier identifier)
        {
            identifier = default;

            foreach (AttachmentIdentifier attId in Features.Items.Firearm.AvailableAttachments.Values.SelectMany(kvp => kvp.Where(kvp2 => kvp2.Name.ToString() == s)))
            {
                identifier = attId;
                return(true);
            }

            return(false);
        }
Example #2
0
 /// <summary>
 /// Indicates whether this instance and a <see cref="AttachmentIdentifier"/> are equal.
 /// </summary>
 /// <param name="attachmentIdentifier">The <see cref="AttachmentIdentifier"/> to compare with the current instance.</param>
 /// <returns><see langword="true"/> if <see cref="AttachmentIdentifier"/> and this instance represent the same value; otherwise, <see langword="false"/>.</returns>
 public bool Equals(AttachmentIdentifier attachmentIdentifier) => this == attachmentIdentifier;