/// <summary> /// Deserialization constructor. /// </summary> /// <param name="serial"></param> /// <exception cref="System.ArgumentNullException">serial</exception> public EvePropertyCategory(SerializablePropertyCategory serial) : base(serial?.Properties.Count ?? 0) { serial.ThrowIfNull(nameof(serial)); ID = serial.ID; Name = serial.Name; Description = serial.Description; foreach (SerializableProperty serialProp in serial.Properties) { Items.Add(new EveProperty(this, serialProp)); } // Sets the display name switch (Name) { default: DisplayName = Name; break; case "NULL": DisplayName = "System"; break; } }
/// <summary> /// Deserialization constructor /// </summary> /// <param name="serial"></param> internal EvePropertyCategory(SerializablePropertyCategory serial) : base(serial.Properties.Length) { m_name = serial.Name; m_description = serial.Description; foreach (var serialProp in serial.Properties) { m_items.Add(new EveProperty(this, serialProp)); } // Sets the display name switch (m_name) { default: m_displayName = m_name; break; case "NULL": m_displayName = "System"; break; } }
/// <summary> /// Exports the attribute categories. /// </summary> /// <returns></returns> private static IEnumerable <SerializablePropertyCategory> ExportAttributeCategories() { List <SerializablePropertyCategory> categories = new List <SerializablePropertyCategory>(); // Export attribute categories List <SerializableProperty> gProperties = new List <SerializableProperty>(); foreach (DgmAttributeCategories srcCategory in Database.DgmAttributeCategoriesTable) { List <SerializableProperty> properties = new List <SerializableProperty>(); SerializablePropertyCategory category = new SerializablePropertyCategory { ID = srcCategory.ID, Description = srcCategory.Description, Name = srcCategory.Name }; categories.Add(category); // Export attributes foreach (DgmAttributeTypes srcProp in Database.DgmAttributeTypesTable.Concat(s_injectedProperties).Where( x => x.CategoryID == category.ID)) { Util.UpdatePercentDone(Database.PropertiesTotalCount); SerializableProperty prop = new SerializableProperty(); properties.Add(prop); prop.ID = srcProp.ID; prop.DefaultValue = srcProp.DefaultValue; prop.Description = srcProp.Description; prop.HigherIsBetter = srcProp.HigherIsBetter; prop.Name = !string.IsNullOrEmpty(srcProp.DisplayName) ? srcProp.DisplayName : !string.IsNullOrEmpty(srcProp.Name) ? srcProp.Name : string.Empty; // Unit prop.UnitID = srcProp.UnitID.GetValueOrDefault(); prop.Unit = srcProp.UnitID.HasValue ? Database.EveUnitsTable.Concat(s_injectedUnits).First( x => x.ID == srcProp.UnitID.Value).DisplayName : string.Empty; // Icon prop.Icon = srcProp.IconID.HasValue ? Database.EveIconsTable[srcProp.IconID.Value].Icon : string.Empty; // Reordering some properties ReorderProperties(gProperties, prop, srcProp, properties); } category.Properties.AddRange(properties); } // New category ID int newCategoryID = Database.DgmAttributeCategoriesTable.Last().ID; // We insert custom categories SerializablePropertyCategory general = new SerializablePropertyCategory { ID = ++newCategoryID, Name = DBConstants.GeneralCategoryName, Description = "General information" }; general.Properties.AddRange(gProperties); categories.Insert(0, general); return(categories); }