private void DetectParser(string[] files) { if (this.parser.IsValidFormat(files)) { this.log.Debug("Confirmed format " + this.parser.ToString()); this.parserDetected = true; } else { IEnumerator enumerator = this.parsers.GetEnumerator(); while (enumerator.MoveNext()) { FTPFileParser current = (FTPFileParser)enumerator.Current; if (current.IsValidFormat(files)) { this.parser = current; this.log.Debug("Detected format " + this.parser.ToString()); this.parserDetected = true; return; } } this.parser = this.unix; this.log.Warn("Could not detect format. Using default " + this.parser.ToString()); } }
/// <summary> /// Detect the parser format to use /// </summary> /// <param name="files"></param> private void DetectParser(string[] files) { // use the initially set parser (from SYST) if (parser.IsValidFormat(files)) { log.Debug("Confirmed format " + parser.ToString()); parserDetected = true; return; } IEnumerator i = parsers.GetEnumerator(); while (i.MoveNext()) { FTPFileParser p = (FTPFileParser)i.Current; if (p.IsValidFormat(files)) { parser = p; log.Debug("Detected format " + parser.ToString()); parserDetected = true; return; } } parser = unix; log.Warn("Could not detect format. Using default " + parser.ToString()); }
private void InitializeParsers() { this.parsers.Add(this.unix); this.parsers.Add(this.windows); this.parsers.Add(this.os400); this.parsers.Add(this.vms); this.parser = this.unix; }
private void InitializeParsers() { parsers.Add(unix); parsers.Add(windows); parsers.Add(os400); parsers.Add(vms); parser = unix; }
/// <summary> Swap from one parser to the other. We can just check /// object references /// </summary> private void RotateParsers() { if (parser == unix) { parser = windows; log.Info("Rotated parser to Windows"); } else if (parser == windows) { parser = unix; log.Info("Rotated parser to Unix"); } }
public FTPFileFactory() { this.log = Logger.GetLogger("FTPFileFactory"); this.windows = new WindowsFileParser(); this.unix = new UnixFileParser(); this.vms = new VMSFileParser(); this.os400 = new OS400FileParser(); this.parser = null; this.parsers = new ArrayList(); this.userSetParser = false; this.parserDetected = false; this.parserCulture = CultureInfo.InvariantCulture; this.timeDiff = new TimeSpan(); this.InitializeParsers(); }
/// <summary> Set the remote server type /// /// </summary> /// <param name="system"> SYST string /// </param> private void SetParser(string system) { this.system = system; if (system.ToUpper().StartsWith(WINDOWS_STR)) { parser = windows; } else if (system.ToUpper().StartsWith(UNIX_STR)) { parser = unix; } else { throw new FTPException("Unknown SYST: " + system); } }
/// <summary> /// Set the remote server type /// </summary> /// <param name="system">SYST string</param> public void SetParser(string system) { parserDetected = false; this.system = system != null?system.Trim() : null; if (system != null) { if (system.ToUpper().StartsWith(WINDOWS_STR)) { log.Debug("Selected Windows parser"); parser = windows; } else if (system.ToUpper().IndexOf(UNIX_STR) >= 0 || system.ToUpper().IndexOf(AIX_STR) >= 0) { log.Debug("Selected UNIX parser"); parser = unix; } else if (system.ToUpper().IndexOf(VMS_STR) >= 0) { log.Debug("Selected VMS parser"); parser = vms; } else if (system.ToUpper().IndexOf(OS400_STR) >= 0) { log.Debug("Selected OS/400 parser"); parser = os400; } else { parser = unix; log.Warn("Unknown SYST '" + system + "' - defaulting to Unix parsing"); } } else { parser = unix; log.Debug("Defaulting to Unix parsing"); } }
public void SetParser(string system) { this.parserDetected = false; this.system = (system != null) ? system.Trim() : null; if (system != null) { if (system.ToUpper().StartsWith("WINDOWS")) { this.log.Debug("Selected Windows parser"); this.parser = this.windows; } else if (system.ToUpper().IndexOf("UNIX") >= 0) { this.log.Debug("Selected UNIX parser"); this.parser = this.unix; } else if (system.ToUpper().IndexOf("VMS") >= 0) { this.log.Debug("Selected VMS parser"); this.parser = this.vms; } else if (system.ToUpper().IndexOf("OS/400") >= 0) { this.log.Debug("Selected OS/400 parser"); this.parser = this.os400; } else { this.parser = this.unix; this.log.Warn("Unknown SYST '" + system + "' - defaulting to Unix parsing"); } } else { this.parser = this.unix; this.log.Debug("Defaulting to Unix parsing"); } }
/// <summary> /// Rather than forcing a parser (as in the constructor that accepts /// a parser), this adds a parser to the list of those used. /// </summary> /// <param name="parser">parser to add to list being used</param> public void AddParser(FTPFileParser parser) { parsers.Add(parser); }
/// <summary> /// Set the remote server type /// </summary> /// <param name="system">SYST string</param> public void SetParser(string system) { parserDetected = false; this.system = system != null ? system.Trim() : null; if (system != null) { if (system.ToUpper().StartsWith(WINDOWS_STR)) { log.Debug("Selected Windows parser"); parser = windows; } else if (system.ToUpper().IndexOf(UNIX_STR) >= 0|| system.ToUpper().IndexOf(AIX_STR) >= 0) { log.Debug("Selected UNIX parser"); parser = unix; } else if (system.ToUpper().IndexOf(VMS_STR) >= 0) { log.Debug("Selected VMS parser"); parser = vms; } else if (system.ToUpper().IndexOf(OS400_STR) >= 0) { log.Debug("Selected OS/400 parser"); parser = os400; } else { parser = unix; log.Warn("Unknown SYST '" + system + "' - defaulting to Unix parsing"); } } else { parser = unix; log.Debug("Defaulting to Unix parsing"); } }
/// <summary> Constructor. User supplied parser. Note that parser /// detection is disabled if a parser is explicitly supplied /// </summary> /// <param name="parser"> the parser to use /// </param> public FTPFileFactory(FTPFileParser parser) { InitializeParsers(); this.parser = parser; }
private void DetectParser(string[] files) { if (this.parser.IsValidFormat(files)) { this.log.Debug("Confirmed format " + this.parser.ToString()); this.parserDetected = true; } else { IEnumerator enumerator = this.parsers.GetEnumerator(); while (enumerator.MoveNext()) { FTPFileParser current = (FTPFileParser) enumerator.Current; if (current.IsValidFormat(files)) { this.parser = current; this.log.Debug("Detected format " + this.parser.ToString()); this.parserDetected = true; return; } } this.parser = this.unix; this.log.Warn("Could not detect format. Using default " + this.parser.ToString()); } }
public void AddParser(FTPFileParser parser) { this.parsers.Add(parser); }
/// <summary> Constructor. User supplied parser. Note that parser /// rotation (in case of a ParseException) is disabled if /// a parser is explicitly supplied /// /// </summary> /// <param name="parser"> the parser to use /// </param> public FTPFileFactory(FTPFileParser parser) { InitBlock(); this.parser = parser; rotateParsersOnFail = false; }
/// <summary> Set the remote server type /// /// </summary> /// <param name="system"> SYST string /// </param> private void SetParser(string system) { this.system = system; if (system.ToUpper().StartsWith(WINDOWS_STR)) parser = windows; else if (system.ToUpper().StartsWith(UNIX_STR)) parser = unix; else throw new FTPException("Unknown SYST: " + system); }