public object getValue(EnumConstant constant, EnumFramework framework = EnumFramework.Default) { var constantModel = constants.Where(a => a.Name.Equals(constant.ToString())).FirstOrDefault(); if (constantModel != null) { String dtype = constantModel.DataType; var value = constantModel.Values.Where(a => a.Framework.ToLower().Equals(framework.ToString().ToLower())).FirstOrDefault(); if (value != null) { bool parseSuccess = false; object parsedData = null; try { var type = Type.GetType(dtype); if (type.Name.ToLower().Equals("string")) { return(value.Value); } parsedData = type.GetMethod("Parse", new[] { typeof(string) }).Invoke(null, new object[] { value.Value }); parseSuccess = true; } catch (Exception ex) { parseSuccess = false; } if (parseSuccess) { return(parsedData); } else { return(null); } } else { return(null); } } else { return(null); } }
public bool updateValue(EnumConstant constant, String str, EnumFramework framework = EnumFramework.Default) { var constantModel = constants.Where(a => a.Name.Equals(constant.ToString())).FirstOrDefault(); if (constantModel != null) { String dtype = constantModel.DataType; var value = constantModel.Values.Where(a => a.Framework.ToLower().Equals(framework.ToString().ToLower())).FirstOrDefault(); if (value != null) { value.Value = str; return(true); } else { return(false); } } else { return(false); } }