public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString) { if (myAGraphDSSharp == null) return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!")); _CancelCommand = false; var _GetDirectoryListingExceptional = myAGraphDSSharp.GetDirectoryListing(ObjectLocation.ParseString(myCurrentPath)); if (_GetDirectoryListingExceptional.Success() && _GetDirectoryListingExceptional.Value != null) { foreach (var _DirectoryEntry in _GetDirectoryListingExceptional.Value) { WriteLine(_DirectoryEntry); } } else { foreach (var _IError in _GetDirectoryListingExceptional.IErrors) WriteLine(_IError.Message); } WriteLine(); return Exceptional.OK; }
public override List<String> Complete(AGraphDSSharp myGraphDSSharp, ref String CurrentPath, string CurrentStringLiteral) { #region Data List<String> _PossibleFSEntries = new List<String>(); IEnumerable<String> _DirectoryElements = null; #endregion if (CurrentStringLiteral.Length.Equals(0)) { try { _DirectoryElements = myGraphDSSharp.GetDirectoryListing(ObjectLocation.ParseString(CurrentPath)).Value; } catch { //do nothing } if (_DirectoryElements != null) { _PossibleFSEntries.AddRange(_DirectoryElements); } } else { #region extract dir prefix from CurrentStringLiteral int indexOfLastPathDelimitter = CurrentStringLiteral.LastIndexOf(FSPathConstants.PathDelimiter); String PrefixDir = CurrentStringLiteral.Substring(0, indexOfLastPathDelimitter + 1); if (CurrentStringLiteral.StartsWith(FSPathConstants.PathDelimiter)) { Boolean directoryExists = false; try { directoryExists = myGraphDSSharp.isIDirectoryObject(ObjectLocation.ParseString(SimplifyObjectLocation(PrefixDir))).Value == Trinary.TRUE; } catch { //do nothing } if (directoryExists) { try { _DirectoryElements = myGraphDSSharp.GetDirectoryListing(ObjectLocation.ParseString(SimplifyObjectLocation(PrefixDir))).Value; } catch { //do nothing } if (_DirectoryElements != null) { foreach (String aDirElement in _DirectoryElements) { _PossibleFSEntries.Add(PrefixDir + aDirElement); } } } } else { if (PrefixDir.Length.Equals(0)) { try { _DirectoryElements = myGraphDSSharp.GetDirectoryListing(ObjectLocation.ParseString(CurrentPath)).Value; } catch { //do nothing } if (_DirectoryElements != null) { _PossibleFSEntries.AddRange(_DirectoryElements); } } else { try { _DirectoryElements = myGraphDSSharp.GetDirectoryListing(ObjectLocation.ParseString(SimplifyObjectLocation(CurrentPath + FSPathConstants.PathDelimiter + PrefixDir))).Value; } catch { //do nothing } if (_DirectoryElements != null) { foreach (String aDirElement in _DirectoryElements) { _PossibleFSEntries.Add(PrefixDir + aDirElement); } } } } #endregion } return _PossibleFSEntries; }