예제 #1
0
        /// <summary>
        /// Create an aggregate from the list of properties in aggrSpec and fill
        /// with values from values array.  This is not publically visible because
        /// it conflicts semantically with setAttribute("foo",new Object[] {...});
        /// </summary>
        public virtual void setAttribute(String aggrSpec, params Object[] values)
        {
            IList properties = new ArrayList();
            String aggrName = null;

            try {
                aggrName = parseAggregateAttributeSpec(aggrSpec, properties);
            }
            catch (ArgumentException) {
                //hmm, maybe they just want to set an attribute to an array value?
                setAttribute(aggrSpec, (Object) values);
                return;
            }

            if (values == null || properties.Count == 0) {
                throw new ArgumentException("missing properties or values for '" + aggrSpec + "'");
            }

            if (values.Length != properties.Count) {
                throw new ArgumentException("number of properties in '" + aggrSpec + "' != number of values");
            }

            Aggregate aggr = new Aggregate();

            for (int i = 0; i < values.Length; i++) {
                Object value = values[i];
                aggr.put((String) properties[i], value);
            }

            setAttribute(aggrName, aggr);
        }