Ejemplo n.º 1
0
 private void GetNewDirectoryResults(string pattern, string directory)
 {
     using (CommandPathSearch.tracer.TraceMethod("pattern: {0} lookupPath: {1}", (object)pattern, (object)directory))
     {
         this.currentDirectoryResults           = CommandPathSearch.GetMatchingPathsInDirectory(pattern, directory);
         this.currentDirectoryResultsEnumerator = this.currentDirectoryResults.GetEnumerator();
     }
 }
Ejemplo n.º 2
0
 public void Dispose()
 {
     if (this.pathSearcher != null)
     {
         this.pathSearcher.Dispose();
         this.pathSearcher = (CommandPathSearch)null;
     }
     this.Reset();
     GC.SuppressFinalize((object)this);
 }
Ejemplo n.º 3
0
 public void Dispose()
 {
     if (this.pathSearcher != null)
     {
         this.pathSearcher.Dispose();
         this.pathSearcher = null;
     }
     this.Reset();
     GC.SuppressFinalize(this);
 }
Ejemplo n.º 4
0
 private void setupPathSearcher()
 {
     if (this.pathSearcher != null)
     {
         return;
     }
     if ((this.commandResolutionOptions & SearchResolutionOptions.CommandNameIsPattern) != SearchResolutionOptions.None)
     {
         this.canDoPathLookup       = true;
         this.canDoPathLookupResult = CommandSearcher.CanDoPathLookupResult.Yes;
         this.pathSearcher          = new CommandPathSearch((IEnumerable <string>) new Collection <string>()
         {
             this.commandName
         }, this._context.CommandDiscovery.GetLookupDirectoryPaths(), this._context);
     }
     else
     {
         this.canDoPathLookupResult = CommandSearcher.CanDoPathLookup(this.commandName);
         if (this.canDoPathLookupResult == CommandSearcher.CanDoPathLookupResult.Yes)
         {
             this.canDoPathLookup = true;
             this.pathSearcher    = new CommandPathSearch(this.ConstructSearchPatternsFromName(this.commandName), this._context.CommandDiscovery.GetLookupDirectoryPaths(), this._context);
         }
         else if (this.canDoPathLookupResult == CommandSearcher.CanDoPathLookupResult.PathIsRooted)
         {
             this.canDoPathLookup = true;
             string directoryName           = Path.GetDirectoryName(this.commandName);
             Collection <string> collection = new Collection <string>();
             collection.Add(directoryName);
             CommandDiscovery.discoveryTracer.WriteLine("The path is rooted, so only doing the lookup in the specified directory: {0}", (object)directoryName);
             string fileName = Path.GetFileName(this.commandName);
             if (!string.IsNullOrEmpty(fileName))
             {
                 this.pathSearcher = new CommandPathSearch(this.ConstructSearchPatternsFromName(fileName), (IEnumerable <string>)collection, this._context);
             }
             else
             {
                 this.canDoPathLookup = false;
             }
         }
         else
         {
             if (this.canDoPathLookupResult != CommandSearcher.CanDoPathLookupResult.DirectorySeparator)
             {
                 return;
             }
             this.canDoPathLookup = true;
             string str = this.ResolvePSPath(Path.GetDirectoryName(this.commandName));
             CommandDiscovery.discoveryTracer.WriteLine("The path is relative, so only doing the lookup in the specified directory: {0}", (object)str);
             if (str == null)
             {
                 this.canDoPathLookup = false;
             }
             else
             {
                 Collection <string> collection = new Collection <string>();
                 collection.Add(str);
                 string fileName = Path.GetFileName(this.commandName);
                 if (!string.IsNullOrEmpty(fileName))
                 {
                     this.pathSearcher = new CommandPathSearch(this.ConstructSearchPatternsFromName(fileName), (IEnumerable <string>)collection, this._context);
                 }
                 else
                 {
                     this.canDoPathLookup = false;
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 private void setupPathSearcher()
 {
     if (this.pathSearcher == null)
     {
         HashSet <string> allowedExtensions = new HashSet <string>();
         allowedExtensions = this._context.CommandDiscovery.GetAllowedExtensionsFromPathExt();
         allowedExtensions.Add(".ps1");
         if ((this.commandResolutionOptions & SearchResolutionOptions.CommandNameIsPattern) != SearchResolutionOptions.None)
         {
             this.canDoPathLookup       = true;
             this.canDoPathLookupResult = CanDoPathLookupResult.Yes;
             Collection <string> patterns = new Collection <string> {
                 this.commandName
             };
             this.pathSearcher = new CommandPathSearch(patterns, this._context.CommandDiscovery.GetLookupDirectoryPaths(), allowedExtensions, false, this._context);
         }
         else
         {
             this.canDoPathLookupResult = CanDoPathLookup(this.commandName);
             if (this.canDoPathLookupResult == CanDoPathLookupResult.Yes)
             {
                 this.canDoPathLookup = true;
                 this.pathSearcher    = new CommandPathSearch(this.ConstructSearchPatternsFromName(this.commandName), this._context.CommandDiscovery.GetLookupDirectoryPaths(), allowedExtensions, false, this._context);
             }
             else if (this.canDoPathLookupResult == CanDoPathLookupResult.PathIsRooted)
             {
                 this.canDoPathLookup = true;
                 string directoryName            = Path.GetDirectoryName(this.commandName);
                 Collection <string> lookupPaths = new Collection <string> {
                     directoryName
                 };
                 CommandDiscovery.discoveryTracer.WriteLine("The path is rooted, so only doing the lookup in the specified directory: {0}", new object[] { directoryName });
                 string fileName = Path.GetFileName(this.commandName);
                 if (!string.IsNullOrEmpty(fileName))
                 {
                     this.pathSearcher = new CommandPathSearch(this.ConstructSearchPatternsFromName(fileName), lookupPaths, allowedExtensions, false, this._context);
                 }
                 else
                 {
                     this.canDoPathLookup = false;
                 }
             }
             else if (this.canDoPathLookupResult == CanDoPathLookupResult.DirectorySeparator)
             {
                 this.canDoPathLookup = true;
                 string path = Path.GetDirectoryName(this.commandName);
                 path = this.ResolvePSPath(path);
                 CommandDiscovery.discoveryTracer.WriteLine("The path is relative, so only doing the lookup in the specified directory: {0}", new object[] { path });
                 if (path == null)
                 {
                     this.canDoPathLookup = false;
                 }
                 else
                 {
                     Collection <string> collection5 = new Collection <string> {
                         path
                     };
                     string str4 = Path.GetFileName(this.commandName);
                     if (!string.IsNullOrEmpty(str4))
                     {
                         this.pathSearcher = new CommandPathSearch(this.ConstructSearchPatternsFromName(str4), collection5, allowedExtensions, false, this._context);
                     }
                     else
                     {
                         this.canDoPathLookup = false;
                     }
                 }
             }
         }
     }
 }