/// <summary>
        /// Used to restrict which attributes get returned by the API.
        /// </summary>
        /// <param name="attributeControls">A params array of <see cref="AttributeToReturn"/> defining which attributes get returned.</param>
        /// <returns>Itself as a <see cref="IReturnedLanguagesConfigureReferences"/>.</returns>
        public IReturnedLanguagesConfigureReferences ReturnAttributes(params IAttributeControl[] attributeControls)
        {
            if (attributeControls != null && attributeControls.Length > 0)
            {
                foreach (IAttributeControl attributeControl in attributeControls)
                {
                    string nodeName = attributeControl.OuterNodeName;

                    if (!this.ControlComponents.Any(cc => cc is AttributeControl && cc.ToAdsml().Name.ToString() == nodeName))
                    {
                        this.ControlComponents.Add(new AttributeControl(nodeName, attributeControl));
                    }
                    else
                    {
                        AttributeControl control =
                            this.ControlComponents.Where(cc => cc is AttributeControl && cc.ToAdsml().Name.ToString() == nodeName)
                            .Cast <AttributeControl>().Single();

                        control.AddAttributes(attributeControl);
                    }
                }
            }

            return(this);
        }
        /// <summary>
        /// Used to restrict which attributes get returned by the API.
        /// </summary>
        /// <param name="definitionIds">A params array of attribute definition ids defining which attributes get returned.</param>
        /// <returns>Itself as a <see cref="IReturnedLanguagesConfigureReferences"/>.</returns>
        public IReturnedLanguagesConfigureReferences ReturnAttributes(params int[] definitionIds)
        {
            if (definitionIds == null || definitionIds.Length <= 0)
            {
                return(this);
            }

            const string nodeName = "AttributesToReturn";

            if (!this.ControlComponents.Any(cc => cc is AttributeControl && cc.ToAdsml().Name.ToString() == nodeName))
            {
                this.ControlComponents.Add(new AttributeControl(nodeName, definitionIds));
            }
            else
            {
                AttributeControl control =
                    this.ControlComponents.Where(cc => cc is AttributeControl && cc.ToAdsml().Name.ToString() == nodeName)
                    .Cast <AttributeControl>().Single();

                string idList =
                    definitionIds
                    .Select(d => d.ToString(CultureInfo.InvariantCulture))
                    .Aggregate((aggr, d) => aggr + ", " + d);

                control.OuterNodeAttributes.Add(new XAttribute("idlist", idList));
            }

            return(this);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="attributeNames"></param>
        /// <returns>Itself as a <see cref="IReturnedAttributesReturnedLanguagesConfigureReferences"/></returns>
        public IReturnedAttributesReturnedLanguagesConfigureReferences AttributeNamelist(string attributeNames)
        {
            if (!string.IsNullOrEmpty(attributeNames))
            {
                var aControl = new AttributeControl("AttributesToReturn")
                {
                    OuterNodeAttributes = new List <XAttribute> {
                        new XAttribute("namelist", attributeNames)
                    }
                };

                this.ControlComponents.Add(aControl);
            }

            return(this);
        }