/// <summary> /// removing a handler from the list of the handlers /// </summary> /// <param name="path">the path of the directory that need to stop handling</param> /// <returns>the result of action (success or failure)</returns> public string RemoveHandler(string path) { bool sucsses = false; string newHandlersList = ""; IDirectoryHandler chosenHandler = null; foreach (IDirectoryHandler handler in this.listOfHandlers) { if (handler.GetPath() == path) { chosenHandler = handler; sucsses = true; } else { newHandlersList += (handler.GetPath() + ";"); } } if (chosenHandler != null) { chosenHandler.CloseHandler(path); ConfigurationManager.AppSettings.Set("Handler", newHandlersList); this.m_logging.Log("The handler of " + path + " removed", MessageTypeEnum.INFO); Thread.Sleep(100); } if (sucsses) { return("sucsses"); } return("failure"); }
/// <summary> /// CloseSpecipicHandler function. /// closes specipic handler. /// </summary> /// <param name="toBeDeletedHandler">path of to be deleted handler</param> internal void CloseSpecipicHandler(string toBeDeletedHandler) { if (Handlers.ContainsKey(toBeDeletedHandler)) { IDirectoryHandler handler = Handlers[toBeDeletedHandler]; this.CloseServer -= handler.CloseHandler; handler.CloseHandler(this, null); } }
/// <summary> /// Close the handler. /// </summary> /// <param name="dir"></param> public void CloseHandlerCommand(string dir) { if (Handlers.ContainsKey(dir)) { IDirectoryHandler handler = Handlers[dir]; CloseServer -= handler.CloseHandler; handler.CloseHandler(this, null); Handlers.Remove(dir); } }