Exemplo n.º 1
0
        /// <summary>
        /// Converts a ValueCollection to a generic list of objects
        /// </summary>
        /// <param name="values">The value collection object</param>
        /// <returns>A generic list of objects</returns>
        public static IList <object> ToList(this ValueCollection values)
        {
            List <object> list = new List <object>();

            foreach (Value value in values.OfType <Value>())
            {
                switch (value.DataType)
                {
                case AttributeType.Binary:
                    list.Add(value.ToBinary());
                    break;

                case AttributeType.Boolean:
                    list.Add(value.ToBoolean());
                    break;

                case AttributeType.Integer:
                    list.Add(value.ToInteger());
                    break;

                case AttributeType.String:
                case AttributeType.Reference:
                    list.Add(value.ToString());
                    break;

                case AttributeType.Undefined:
                default:
                    throw new UnknownOrUnsupportedDataTypeException();
                }
            }

            return(list);
        }