/// <summary> /// Adds the meta data. /// </summary> /// <param name="item">The item.</param> /// <param name="propInt64Value">The prop int value.</param> /// <param name="srcProp">The SRC prop.</param> private static void AddMetaData(SerializableItem item, long propInt64Value, DgmTypeAttributes srcProp) { // Is metalevel property ? switch (srcProp.AttributeID) { case DBConstants.MetaLevelPropertyID: item.MetaLevel = propInt64Value; break; // Is techlevel property ? case DBConstants.TechLevelPropertyID: switch (propInt64Value) { case DBConstants.TechLevelII: item.MetaGroup = ItemMetaGroup.T2; break; case DBConstants.TechLevelIII: item.MetaGroup = ItemMetaGroup.T3; break; default: item.MetaGroup = ItemMetaGroup.T1; break; } break; // Is metagroup property ? case DBConstants.MetaGroupPropertyID: switch (propInt64Value) { case DBConstants.StorylineMetaGroupID: item.MetaGroup = ItemMetaGroup.Storyline; break; case DBConstants.FactionMetaGroupID: item.MetaGroup = ItemMetaGroup.Faction; break; case DBConstants.OfficerMetaGroupID: item.MetaGroup = ItemMetaGroup.Officer; break; case DBConstants.DeadspaceMetaGroupID: item.MetaGroup = ItemMetaGroup.Deadspace; break; default: item.MetaGroup = ItemMetaGroup.None; break; } break; default: break; } }
/// <summary> /// Formats a properties value in a human friendly manner. /// </summary> /// <param name="property">The property.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">property</exception> public static string FormatPropertyValue(this DgmTypeAttributes property) { property.ThrowIfNull(nameof(property)); // Is it actually an integer stored as a float? if (property.ValueFloat.HasValue && Math.Abs(Math.Truncate(property.ValueFloat.Value) - property.ValueFloat.Value) < float.Epsilon) { return(Convert.ToInt64(property.ValueFloat.Value).ToString(CultureInfo.InvariantCulture)); } return(property.ValueInt64.HasValue ? property.ValueInt64.ToString() : property.ValueFloat.ToString()); }
/// <summary> /// Adds a single item property to the list if it is found in the list of recognized /// property IDs. /// </summary> /// <param name="ids">The property IDs to search.</param> /// <param name="attrib">The attribute to add.</param> /// <param name="props">The property list to add the attribute, if found.</param> /// <returns>true if the attribute was found and added, or false otherwise.</returns> private static bool AddItemProp(IReadOnlyCollection <int> ids, DgmTypeAttributes attrib, IList <SerializablePropertyValue> props) { int id = attrib.AttributeID, index = ids.IndexOf(id); if (index >= 0) { // Index was found in the list of known IDs long propInt64Value = attrib.GetInt64Value; var invGroups = Database.InvGroupsTable; props.Add(new SerializablePropertyValue { ID = id, Value = invGroups.HasValue(propInt64Value) ? invGroups[propInt64Value].Name : string.Empty }); } return(index > -1); }