/// <summary> /// Try to get the enum field that defines the given constant. /// </summary> public override bool TryGetEnumConstField(object value, out XFieldDefinition field) { field = null; if (!type.IsEnum || (value == null)) { return(false); } var valueType = value.GetType(); var ilField = type.Fields.FirstOrDefault(x => x.IsStatic && Equals(XConvert.ChangeType(x.Constant, valueType), value)); if (ilField == null) { return(false); } field = Fields.OfType <ILFieldDefinition>().FirstOrDefault(x => x.OriginalField == ilField); return(field != null); }