/**
         * This method simply catches responses and calls the 
         * configured {@link ResponseHandler} to process them. 
         * 
         * @param response {@link Response} that has been added to the {@link ResponseStore}.
         */
        //public override void analyze(Response response) {
        public void analyze(Response response) {
            if(response != null) {
                Logger.Info("Response executed for user <" + response.GetUser().getUsername() + "> - executing response action " + response.getAction());

                appSensorClient.getResponseHandler().handle(response);
            }
        }
	/**
	 * {@inheritDoc}
	 */
	//public override void handle(Response response) {
    public new void handle(Response response) {

        if(ResponseHandler.LOG.Equals(response.getAction())) {
			Logger.Error("Response executed for user:"******", Action: Increased Logging");
        } else if(ResponseHandler.LOGOUT.Equals(response.getAction())) {
			Logger.Error("Response executed for user:"******", Action: Logging out malicious account");
			
			appSensorClient.getUserManager().logout(response.GetUser());
        } else if(ResponseHandler.DISABLE_USER.Equals(response.getAction())) {
			Logger.Error("Response executed for user:"******", Action: Disabling malicious account");
			
			appSensorClient.getUserManager().logout(response.GetUser());
        } else if(ResponseHandler.DISABLE_COMPONENT_FOR_SPECIFIC_USER.Equals(response.getAction())) {
			Logger.Error("Response executed for user:"******", Action: Disabling Component for Specific User");
			
			//TODO: fill in real code for disabling component for specific user
        } else if(ResponseHandler.DISABLE_COMPONENT_FOR_ALL_USERS.Equals(response.getAction())) {
			Logger.Error("Response executed for user:"******", Action: Disabling Component for All Users");
			
			//TODO: fill in real code for disabling component for all users
		} else {
			//throw new IllegalArgumentException("There has been a request for an action " +
            throw new ArgumentException("There has been a request for an action " +
					"that is not supported by this response handler.  The requested action is: " + response.getAction());
		}
		
	}
        /**
         * {@inheritDoc}
         */
        public override void addResponse(Response response) {
            Logger.Warn("Security response " + response + " triggered for user: " + response.GetUser().getUsername());

            writeResponse(response);

            base.notifyListeners(response);
        }
	/**
	 * {@inheritDoc}
	 */
	//public override void onAdd(Response response) {
    public void onAdd(Response response) {
		notifyWebSocket("response", response);
		
		Logger.Info("Reporter observed response for user [" + response.GetUser().getUsername() + "]");
	}
 public void analyze(Response response) {
 }
 public void onAdd(Response response) {
     analyze( response); 
 }
    /// <exception cref="XMLStreamException"></exception>
	private Response readResponse(XmlReader xmlReader) {
		Response response = new Response();
		bool finished = false;
		
		while(!finished && xmlReader.MoveToNextAttribute()) {
			//int Event = xmlReader.next();
			string name = XmlUtils.getElementQualifiedName(xmlReader, namespaces);
			
			switch(xmlReader.NodeType) {
				case XmlNodeType.Element:
					if("config:action".Equals(name)) {
						response.setAction(xmlReader.ReadString().Trim());
					} else if("config:interval".Equals(name)) {
						Interval interval = new Interval();
                        // interval.setUnit(xmlReader.getAttributeValue(null, "unit").Trim());
                        interval.setUnit(xmlReader.GetAttribute("unit", null).Trim());
                        /*
                         * getAttributeValue takes as parameters namespaceURI and localName
                         * GetAttribute takes as parameters localName and namespaceURI
                         * 
                         * Migrator's note.
                         */
                        interval.setDuration(Int32.Parse(xmlReader.ReadString().Trim()));
						response.setInterval(interval);
					} else {
						/** unexpected start element **/
                    }
					break;
				case XmlNodeType.EndElement:
					if("config:response".Equals(name)) {
						finished = true;
					} else {
						/** unexpected end element **/
					}
					break;
				default:
					/** unused xml element - nothing to do **/
					break;
			}
		}
		
		return response;
	}
	/**
	 * Notify each {@link ResponseListener} of the specified {@link Response}
	 * 
	 * @param response the {@link Response} to notify each {@link ResponseListener} about
	 */
	public void notifyListeners(Response response) {
		foreach (ResponseListener listener in listeners) {
			listener.OnAdd(response);
		}
	}
	/**
	 * Add a response to the ResponseStore
	 * 
	 * @param response {@link org.owasp.appsensor.Response} to Add to the ResponseStore
	 */
	public abstract void addResponse(Response response);
        protected void writeResponse(Response response) {
            //string json = gson.toJson(response);
            string json = ser.ToString();

            try {
                //Files.write(getPath(), Arrays.asList(json), StandardCharsets.UTF_8, StandardOpenOption.APPEND, StandardOpenOption.WRITE);
                File.WriteAllText(getPath().ToString(), json, System.Text.Encoding.UTF8);
            } catch(IOException e) {
                Logger.Error("Error occurred loading writing event file to path: " + getPath(), e);
            }
        }
	/**
	 * {@inheritDoc}
	 */
	//public override void onAdd(Response response) {
    public  void onAdd(Response response) {
		Logger.Info("Reporter observed response for user [" + response.GetUser().getUsername() + "]");
	}