public static IFileServiceCommand NewCommand(string cmd) { IFileServiceCommand result = null; Type fsCommandType = Type.GetType(CommadList.Get(cmd), false, true); if (fsCommandType != null) { System.Reflection.ConstructorInfo ci = fsCommandType.GetConstructor(new Type[] { }); result = (IFileServiceCommand)ci.Invoke(new object[] { }); } else { throw new FileServiceCommandExeption($"Commnand \"{cmd}\" not found"); } return(result); }
public string RunCommand(string cmd) { string fsCommand = cmd.Split(' ')[0]; string[] args = cmd.Split(' ').Skip(1).ToArray(); try { IFileServiceCommand fsCommandObj = FileServiceCommands.NewCommand(fsCommand.ToLower()); string answer = fsCommandObj.Run(OperationContext.Current.SessionId, args); OperationContext.Current.GetCallbackChannel <IFileServiceCallback>().Notify(FileServiceSession.GetUser(OperationContext.Current.SessionId) + " " + fsCommandObj.Notify(args)); return(answer); } catch (FileServiceCommandExeption e) { return($"Error: {e.Message}"); } finally { if (Monitor.IsEntered(VirtualFileSystem.Lock)) { Monitor.Exit(VirtualFileSystem.Lock); } } }