public EocConstantInfo GetEocConstantInfo(int libraryId, int id) { switch (libraryId) { case -2: return(GetEocConstantInfo(id)); default: var name = Libs[libraryId].Constant[id].Name; EocConstantInfo result; try { result = EocLibs[libraryId].Constant[name]; } catch (Exception) { result = new EocConstantInfo() { Value = Libs[libraryId].Constant[id].Value }; if (result.Value is long longValue) { if ((int)longValue == longValue) { result.Value = (int)longValue; } } result.DataType = EocDataTypes.GetConstValueType(result.Value); } return(result); } }
public EocConstantInfo GetEocConstantInfo(EmnuConstantExpression expr) { var dataTypeInfo = Libs[expr.LibraryId].DataType[expr.StructId]; var memberInfo = dataTypeInfo.Member[expr.MemberId]; EocConstantInfo result; try { result = EocLibs[expr.LibraryId].Enum[dataTypeInfo.Name][memberInfo.Name]; } catch (Exception) { result = new EocConstantInfo() { Value = memberInfo.Default }; if (result.Value is long longValue) { if ((int)longValue == longValue) { result.Value = (int)longValue; } } result.DataType = EocDataTypes.GetConstValueType(result.Value); } return(result); }