/// <summary> /// Is equivalent to Enum.GetValues(typeof(InventoryUnitType)) without default value /// </summary> /// <param name="unitType"></param> /// <returns></returns> internal static IEnumerable <InventoryUnitType> Split(this InventoryUnitType unitType) { if ((unitType & InventoryUnitType.PurchaseUnit) != 0) { yield return(InventoryUnitType.PurchaseUnit); } if ((unitType & InventoryUnitType.SalesUnit) != 0) { yield return(InventoryUnitType.SalesUnit); } if ((unitType & InventoryUnitType.BaseUnit) != 0) { yield return(InventoryUnitType.BaseUnit); } }
internal static string GetUnitID(this InventoryItem inventoryItem, InventoryUnitType inventoryUnitType) { switch (inventoryUnitType) { case InventoryUnitType.None: return(null); case InventoryUnitType.BaseUnit: return(inventoryItem.BaseUnit); case InventoryUnitType.SalesUnit: return(inventoryItem.SalesUnit); case InventoryUnitType.PurchaseUnit: return(inventoryItem.PurchaseUnit); default: throw new ArgumentOutOfRangeException(nameof(inventoryUnitType)); } }