Cryptid.Candidate.GetEyeColor C# (CSharp) Method

GetEyeColor() public method

Gets the EyeColor enum from a string representing the eye color
public GetEyeColor ( string s ) : EyeColor
s string
return EyeColor
        public EyeColor GetEyeColor(string s)
        {
            foreach (EyeColor ec in Enum.GetValues(typeof (EyeColor))) {
                string val = null;
                var type = ec.GetType();
                var fi = type.GetField(ec.ToString());
                var attrs = fi.GetCustomAttributes(typeof (StringValue), false) as StringValue[];
                if (attrs != null && attrs.Length > 0) val = attrs[0].Value;
                if (val != null && val.Equals(s)) return ec;
            }
            return EyeColor.Unknown;
        }