Ejemplo n.º 1
0
        /// <summary>
        /// Allergenses to string.
        /// </summary>
        /// <returns></returns>
        private static string AllergensToString(Allergen allergens)
        {
            StringBuilder sb = new StringBuilder();
            int allergensValue = (int)allergens;
            int value = 1;
            for (int i = 1; i <= 14; i++)
            {
                if ((allergensValue & value) != 0)
                {
                    if (sb.Length > 0)
                        sb.Append(", ");

                    sb.Append(i);
                }

                value *= 2;
            }

            return sb.ToString();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Foods the title with allergens to string.
 /// </summary>
 /// <param name="foodTitle">The food title.</param>
 /// <param name="allergens">The allergens.</param>
 /// <returns></returns>
 private static string FoodTitleWithAllergensToString(string foodTitle, Allergen allergens)
 {
     return foodTitle + BorderLabel.GetSizeTag(-4) + "  " + AllergensToString(allergens);
 }