/*private ServerConfiguration readServerConfiguration(XmlReader xmlReader) {
         *  ServerConfiguration configuration = new StaxServerConfiguration(false);
         *  bool finished = false;
         *
         *  while(!finished && xmlReader.hasNext()) {
         *      //int Event = xmlReader.next();
         *      string name = XmlUtils.getElementQualifiedName(xmlReader, namespaces);
         *
         *      switch(Event) {
         *          case XMLStreamConstants.START_ELEMENT:
         *              if("config:appsensor-server-config".Equals(name)) {
         *                  //
         *              } else if("config:client-application-identification-header-name".Equals(name)) {
         *                  configuration.setClientApplicationIdentificationHeaderName(xmlReader.getElementText().Trim());
         *              } else if("config:client-applications".Equals(name)) {
         *                  configuration.getClientApplications().addAll(readClientApplications(xmlReader));
         *              } else if("config:correlation-config".Equals(name)) {
         *                  configuration.getCorrelationSets().addAll(readCorrelationSets(xmlReader));
         *              } else if("config:detection-point".Equals(name)) {
         *                  configuration.getDetectionPoints().Add(readDetectionPoint(xmlReader));
         *              } else {
         *                  /** unexpected start element **
         *              }
         *              break;
         *          case XMLStreamConstants.END_ELEMENT:
         *              if("config:appsensor-server-config".Equals(name)) {
         *                  finished = true;
         *              } else {
         *                  /** unexpected end element **
         *              }
         *              break;
         *          default:
         *              /** unused xml element - nothing to do **
         *              break;
         *      }
         *  }
         *
         *  return configuration;
         * }*/

        /// <exception cref="XMLStreamException"></exception>
        private ServerConfiguration readServerConfiguration(XmlReader xmlReader)
        {
            ServerConfiguration configuration = new StaxServerConfiguration(false);
            bool finished = false;

            while (!finished && xmlReader.Read())
            {
                //int Event = xmlReader.next();
                string name = XmlUtils.getElementQualifiedName(xmlReader, namespaces);

                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                    if ("config:appsensor-server-config".Equals(name))
                    {
                        //
                    }
                    else if ("config:client-application-identification-header-name".Equals(name))
                    {
                        configuration.setClientApplicationIdentificationHeaderName(xmlReader.ReadString().Trim());
                    }
                    else if ("config:client-applications".Equals(name))
                    {
                        configuration.getClientApplications().UnionWith(readClientApplications(xmlReader));
                    }
                    else if ("config:correlation-config".Equals(name))
                    {
                        configuration.getCorrelationSets().UnionWith(readCorrelationSets(xmlReader));
                    }
                    else if ("config:detection-point".Equals(name))
                    {
                        configuration.getDetectionPoints().Add(readDetectionPoint(xmlReader));
                    }
                    else
                    {
                        /** unexpected start element **/
                    }
                    break;

                case XmlNodeType.EndElement:
                    if ("config:appsensor-server-config".Equals(name))
                    {
                        finished = true;
                    }
                    else
                    {
                        /** unexpected end element **/
                    }
                    break;

                default:
                    /** unused xml element - nothing to do **/
                    break;
                }
            }

            return(configuration);
        }
    /*private ServerConfiguration readServerConfiguration(XmlReader xmlReader) {
        ServerConfiguration configuration = new StaxServerConfiguration(false);
        bool finished = false;

        while(!finished && xmlReader.hasNext()) {
            //int Event = xmlReader.next();
            string name = XmlUtils.getElementQualifiedName(xmlReader, namespaces);

            switch(Event) {
                case XMLStreamConstants.START_ELEMENT:
                    if("config:appsensor-server-config".Equals(name)) {
                        //
                    } else if("config:client-application-identification-header-name".Equals(name)) {
                        configuration.setClientApplicationIdentificationHeaderName(xmlReader.getElementText().Trim());
                    } else if("config:client-applications".Equals(name)) {
                        configuration.getClientApplications().addAll(readClientApplications(xmlReader));
                    } else if("config:correlation-config".Equals(name)) {
                        configuration.getCorrelationSets().addAll(readCorrelationSets(xmlReader));
                    } else if("config:detection-point".Equals(name)) {
                        configuration.getDetectionPoints().Add(readDetectionPoint(xmlReader));
                    } else {
                        /** unexpected start element **
                    }
                    break;
                case XMLStreamConstants.END_ELEMENT:
                    if("config:appsensor-server-config".Equals(name)) {
                        finished = true;
                    } else {
                        /** unexpected end element **
                    }
                    break;
                default:
                    /** unused xml element - nothing to do **
                    break;
            }
        }

        return configuration;
    }*/

    /// <exception cref="XMLStreamException"></exception>
	private ServerConfiguration readServerConfiguration(XmlReader xmlReader) {
		ServerConfiguration configuration = new StaxServerConfiguration(false);
		bool finished = false;
		
		while(!finished && xmlReader.Read()) {
            //int Event = xmlReader.next();
			string name = XmlUtils.getElementQualifiedName(xmlReader, namespaces);

			switch(xmlReader.NodeType) {
                case XmlNodeType.Element:
					if("config:appsensor-server-config".Equals(name)) {
						//
					} else if("config:client-application-identification-header-name".Equals(name)) {
                        configuration.setClientApplicationIdentificationHeaderName(xmlReader.ReadString().Trim());
					} else if("config:client-applications".Equals(name)) {
						configuration.getClientApplications().UnionWith(readClientApplications(xmlReader));
					} else if("config:correlation-config".Equals(name)) {
						configuration.getCorrelationSets().UnionWith(readCorrelationSets(xmlReader));
					} else if("config:detection-point".Equals(name)) {
						configuration.getDetectionPoints().Add(readDetectionPoint(xmlReader));
					} else {
						/** unexpected start element **/
					}
					break;
				case XmlNodeType.EndElement:
					if("config:appsensor-server-config".Equals(name)) {
						finished = true;
					} else {
						/** unexpected end element **/
					}
					break;
				default:
					/** unused xml element - nothing to do **/
					break;
			}
		}
		
		return configuration;
	}