Example #1
0
        /// <summary>
        /// Serialize collection of objects with names to string.
        /// </summary>
        /// <param name="specialities">Collection of objects to serialize.</param>
        /// <returns>String with collection elements names.</returns>
        private string _SerializeNames(IEnumerable specialities)
        {
            if (specialities == null)
            {
                return(null);
            }

            // Get names from objects collection.
            var names = new List <string>();

            foreach (ISupportName spec in specialities)
            {
                names.Add(spec.Name);
            }

            if (names.Count == 0)
            {
                return(null);
            }

            // Serialize names list.
            var speciality = new Specialities();

            speciality.Names = names;
            return(JsonSerializeHelper.Serialize(speciality));
        }
Example #2
0
        /// <summary>
        /// Serialize collection of objects with names to string.
        /// </summary>
        /// <param name="specialities">Collection of objects to serialize.</param>
        /// <returns>String with collection elements names.</returns>
        private string _SerializeNames(IEnumerable specialities)
        {
            if (specialities == null)
                return null;

            // Get names from objects collection.
            var names = new List<string>();
            foreach (ISupportName spec in specialities)
                names.Add(spec.Name);

            if (names.Count == 0)
                return null;

            // Serialize names list.
            var speciality = new Specialities();
            speciality.Names = names;
            return JsonSerializeHelper.Serialize(speciality);
        }