private InterpreterConfiguration(Dictionary <string, object> properties) { Id = Read(properties, nameof(Id)); _description = Read(properties, nameof(Description)) ?? ""; InterpreterPath = Read(properties, nameof(InterpreterPath)); PathEnvironmentVariable = Read(properties, nameof(PathEnvironmentVariable)); LibraryPath = Read(properties, nameof(LibraryPath)); Architecture = InterpreterArchitecture.TryParse(Read(properties, nameof(Architecture))); try { Version = Version.Parse(Read(properties, nameof(Version))); } catch (Exception ex) when(ex is ArgumentException || ex is FormatException) { Version = new Version(); } if (properties.TryGetValue(nameof(SearchPaths), out object o)) { SearchPaths.Clear(); if (o is string s) { SearchPaths.AddRange(s.Split(';')); } else if (o is IEnumerable <string> ss) { SearchPaths.AddRange(ss); } } }
private void FindNativeLibrarySearchPaths(string ldConfigPath) { string line; if (!File.Exists(ldConfigPath)) { return; } using (var reader = new StreamReader(ldConfigPath)) { while ((line = reader.ReadLine()) != null) { line = line.Trim(); if (line.StartsWith("include ")) { var expr = line.Substring(8); var dir = Path.GetDirectoryName(expr); expr = expr.Substring(expr.LastIndexOf(Path.DirectorySeparatorChar) + 1); foreach (var path in Directory.GetFiles(dir, expr)) { FindNativeLibrarySearchPaths(path); } } else { SearchPaths.Add(line); } } } }
public List <string> ListFiles() { List <string> result = new List <string>(); foreach (string searchPath in SearchPaths.Split(';')) { string directory; SearchOption option; if (Path.GetFileName(searchPath) == "**") { directory = Path.GetDirectoryName(searchPath); option = SearchOption.AllDirectories; } else { directory = searchPath; option = SearchOption.TopDirectoryOnly; } foreach (string fileMask in FileMasks.Split(';')) { foreach (string fileName in Directory.GetFiles(directory, fileMask, option)) { string extension = Path.GetExtension(fileName); if (!String.Equals(extension, ".dproj", StringComparison.InvariantCultureIgnoreCase)) { result.Add(fileName); } } } } return(result); }
internal override Task ResolveView(ResolveViewArgs resolveViewArgs) { if (resolveViewArgs.Success == true) { return(Task.CompletedTask); } var path = new[] { resolveViewArgs.Name } .SelectMany(pattern => ViewExtensions.Select(ext => $"{pattern}{ext}")) .SelectMany(pattern => SearchPaths.Select(searchPath => CombineAndRestrictPath(searchPath, pattern))) .Where(_ => File.Exists(_)) .FirstOrDefault(); if (path == null) { return(Task.CompletedTask); } if (RoutableOptions.TryGetMimeType(Path.GetExtension(path), out var mimeType) == false) { mimeType = DefaultMimeType; } resolveViewArgs.MimeType = mimeType; resolveViewArgs.LastModified = File.GetLastWriteTimeUtc(path); resolveViewArgs.GetStream = () => Task.FromResult <Stream>(File.OpenRead(path)); resolveViewArgs.Success = true; return(Task.CompletedTask); }
public void Run() { var start = DateTime.Now; Console.Out.WriteLine("BaseSearchFolder: " + BaseSearchFolder); SearchPaths.ForEach(folder => { if (!Path.IsPathRooted(folder) && !string.IsNullOrEmpty(BaseSearchFolder)) { folder = Path.Combine(BaseSearchFolder, folder); } int currentCount = bag.Count; Console.Out.WriteLine("Analyzing " + folder); if (Directory.Exists(folder)) { findResourcesInFolder(folder, folder); Console.Out.WriteLine(" found " + (bag.Count - currentCount) + " matches..."); } else { Console.WriteLine("Error: The directory doesn't exist."); } Console.Out.WriteLine(""); }); Console.Out.WriteLine("Process was completed in " + (DateTime.Now.Subtract(start).TotalMilliseconds + " ms")); Task.Run(() => createOutputFile()); }
public void AddSearchPath(string path) { // Invalidate the cache expandedPCorePaths = null; // Add the search path SearchPaths.Add(path); }
/// <summary> /// Adds the search path. /// </summary> /// <param name="path">The path.</param> public void AddSearchPath(string path) { if (string.IsNullOrWhiteSpace(path)) { return; } SearchPaths.AddIfNew(path); }
private void InitSearchPaths() { var paths = SearchPaths .Split(';') .Select(p => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p)) .ToList(); IronRubyEngine.Engine.SetSearchPaths(paths); }
private void SearchPathItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "RemoveItem") { var item = sender as SearchPathItemViewModel; SearchPaths.Remove(item); item.PropertyChanged -= SearchPathItem_PropertyChanged; } }
/// <summary> /// Initializes search path from the value of the environment variable "PATH". /// </summary> public void InitializeSearchPathFromCurrentEnvironment() { char[] sep = new char[] { ';' }; foreach (string s in Environment.GetEnvironmentVariable("PATH").Split(sep, StringSplitOptions.RemoveEmptyEntries)) { if (Directory.Exists(s)) { SearchPaths.Add(s); } } }
private void OnEnable() { searchSpecificFolders = EditorPrefs.GetBool("SOUpdater_SearchSpecificFolders"); List <string> searchPathList = GetSearchPaths(); paths = new SearchPaths() { arraySize = searchPathList.Count, pathsToSearch = searchPathList }; }
static void SetupDefaultIncludePaths(SearchPaths searchPaths) { searchPaths.AddSearchPath(Environment.CurrentDirectory); string[] includePaths = (Environment.GetEnvironmentVariable("INCLUDE") ?? string.Empty).Split(';'); foreach (string includePath in includePaths) { if (!searchPaths.AddSearchPath(includePath)) { Console.WriteLine($"Couldn't find '{includePath}' specified in %INCLUDE%"); } } }
protected override OptionSet OnCreateOptions() => new OptionSet { { "cache=", "The package cache directory", v => PackageCache = v }, { "group-ids", "Group the output by package ID", v => GroupByPackageId = true }, { "group-versions", "Group the output by version", v => GroupByVersion = true }, { "latest", "Compare against the latest", v => Latest = true }, { "output=", "The output directory", v => OutputDirectory = v }, { "prerelease", "Include preprelease packages", v => PrePrelease = true }, { "ignore-unchanged", "Ignore unchanged packages and assemblies", v => IgnoreUnchanged = true }, { "search-path=", "A search path directory", v => SearchPaths.Add(v) }, { "source=", "The NuGet URL source", v => SourceUrl = v }, { "version=", "The version of the package to compare", v => Version = v }, };
static void Main(string[] args) { SearchPaths searchPaths = new SearchPaths(); SetupDefaultIncludePaths(searchPaths); CommandLineOptions options = new CommandLineOptions(); Utilities.CommandLineSwitchParser commandLineParser = new Utilities.CommandLineSwitchParser(); // todo: catch exceptions commandLineParser.Parse(args, options); // Parse command line arguments foreach (var path in options.I) { if (!string.IsNullOrEmpty(path) && !searchPaths.AddSearchPath(path)) { Console.WriteLine($"Couldn't add include directory '{path}'"); } } // Find all cpp and header files Console.WriteLine("Finding source files..."); IEnumerable <string> cppFilesToSearch = Directory.EnumerateFiles(Environment.CurrentDirectory, "*.cpp", SearchOption.AllDirectories); IEnumerable <string> hFilesToSearch = Directory.EnumerateFiles(Environment.CurrentDirectory, "*.h", SearchOption.AllDirectories); List <string> allFiles = new List <string>(); allFiles.AddRange(cppFilesToSearch); allFiles.AddRange(hFilesToSearch); Console.WriteLine($"{allFiles.Count} files found."); Regex includeRegex = new Regex(@"^\s*#include\s+[""<]([^""<>]+?)["">]", RegexOptions.Singleline | RegexOptions.Compiled); UniqueNodeList uniqueNodes = new UniqueNodeList(searchPaths, includeRegex); // Read each file HashSet <string> visited = new HashSet <string>(); foreach (var file in allFiles) { Node node = uniqueNodes.GetNodeForPath(file); uniqueNodes.BuildHierarchy(node); Console.WriteLine(Tabulate(node.FilePath, 0)); PrintNode(node, 1, visited); } }
/// <summary> /// Creates a new <see cref="ScriptOptions"/> with the search paths changed. /// </summary> /// <exception cref="ArgumentNullException"><paramref name="searchPaths"/> is null or contains a null reference.</exception> public ScriptOptions WithSearchPaths(IEnumerable <string> searchPaths) { if (searchPaths != null && SearchPaths.SequenceEqual(searchPaths)) { return(this); } // TODO: var resolver = new AssemblyReferenceResolver( _referenceResolver.PathResolver.WithSearchPaths(ToImmutableArrayChecked(searchPaths, nameof(searchPaths))), _referenceResolver.Provider); return(With(resolver: resolver)); }
internal void WriteToDictionary(Dictionary <string, object> properties) { properties[nameof(Id)] = Id; properties[nameof(Description)] = _description; properties[nameof(InterpreterPath)] = InterpreterPath; properties[nameof(PathEnvironmentVariable)] = PathEnvironmentVariable; properties[nameof(LibraryPath)] = LibraryPath; properties[nameof(Architecture)] = Architecture.ToString(); if (Version != null) { properties[nameof(Version)] = Version.ToString(); } properties[nameof(SearchPaths)] = SearchPaths.ToArray(); }
public LaunchConfiguration Clone(InterpreterConfiguration newConfig = null) { return(new LaunchConfiguration(newConfig ?? _config, _options) { PreferWindowedInterpreter = PreferWindowedInterpreter, InterpreterPath = InterpreterPath, InterpreterArguments = InterpreterArguments, ScriptName = ScriptName, ScriptArguments = ScriptArguments, WorkingDirectory = WorkingDirectory, Environment = Environment != null ? new Dictionary <string, string>(Environment) : null, SearchPaths = SearchPaths?.ToList() }); }
private void FindNativeLibrarySearchPaths() { foreach (var var in new [] { "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH" }) { var value = Environment.GetEnvironmentVariable(var); if (!String.IsNullOrEmpty(value)) { foreach (var path in value.Split(':')) { SearchPaths.Add(path); } } } FindNativeLibrarySearchPaths("/etc/ld.so.conf"); }
public FileExports GetFileExports(string filename, bool addDirectoryToSearchPaths = false) { if (addDirectoryToSearchPaths && Path.IsPathRooted(filename) && File.Exists(filename)) { SearchPaths.Add(Path.GetDirectoryName(filename)); } List<string> candidates = ResolveFilename(filename); FileExports firstResult = null; foreach (string candidate in candidates) { var fileInfo = new FileInfo(candidate); var fullName = fileInfo.FullName; if (AllFileExports.ContainsKey(fullName)) { return AllFileExports[fullName]; } var records = DumpBinProcessor_Obsolete.GetExports_Obsolete(fullName); var fileExports = new FileExports() { StartingFilePath = fullName }; foreach (var record in records) { fileExports.Records.Add(record); if (!string.IsNullOrEmpty(record.Prototype) && !fileExports.LookupByPrototype.ContainsKey(record.Prototype)) { fileExports.LookupByPrototype.Add(record.Prototype, record); } if (!string.IsNullOrEmpty(record.DecoratedName) && !fileExports.LookupByDecoratedName.ContainsKey(record.DecoratedName)) { fileExports.LookupByDecoratedName.Add(record.DecoratedName, record); } } AllFileExports.Add(fullName, fileExports); if (firstResult == null) { firstResult = fileExports; } } return firstResult; }
/// <summary> /// Get the search result /// </summary> /// <param name="actNode">The actual Node</param> /// <returns>Return IENumerable value which is te search value</returns> private IEnumerable GetResult(Node actNode) { var queryString = string.Empty; if (Context.Request.Params.Get("TagFilter") != null) { queryString = Context.Request.Params.Get("TagFilter"); } if (actNode.NodeType.Id == ActiveSchema.NodeTypes["Tag"].Id) { queryString = actNode.Name; } char[] splitchars = { ',' }; var contentTypeArray = ContentTypes.Split(splitchars, StringSplitOptions.RemoveEmptyEntries); var searchPathArray = SearchPaths.ToLower().Split(splitchars, StringSplitOptions.RemoveEmptyEntries); var allTypes = new List <string>(); foreach (var type in contentTypeArray) { allTypes.Add(type.ToLower()); if (IncludeChildren)//if all descendant types are needed { var baseType = ContentType.GetByName(type); if (baseType != null) { foreach (var childType in ContentType.GetContentTypes()) { if (childType.IsDescendantOf(baseType)) { allTypes.Add(childType.Name.ToLower()); } } } } } var contentsId = TagManager.GetNodeIds(queryString, searchPathArray, allTypes.ToArray(), QueryFilter); var result = new NodeList <Node>(contentsId); return(result); }
public override void Execute(object parameter) { var selectedFileTreeItem = GetSelectedFileTreeItem(); if (selectedFileTreeItem == null) { return; } var itemPath = selectedFileTreeItem.ItemPath; if (!CanAddPath(itemPath)) { return; } SearchPaths.Add(new SearchPath(itemPath, InclusionType.Include)); Enabled = false; }
/// <summary> /// Creates custom controls using the given content view. /// </summary> private void CreateControls() { try { var viewControl = Page.LoadControl(ContentViewPath) as Controls.TagAdminControl; if (viewControl != null) { viewControl.TagPath = Tags; viewControl.SearchPaths = SearchPaths.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); Controls.Add(viewControl); } } catch (Exception ex) { Logger.WriteException(ex); Controls.Clear(); Controls.Add(new LiteralControl("ContentView error: " + ex.Message)); } }
/// <summary> /// Function to find a plug-in assembly on a given path. /// </summary> /// <param name="plugInPath">Initial path to the plug-in</param> /// <returns>The assembly name for the plug-in assembly.</returns> private AssemblyName FindPlugInAssembly(string plugInPath) { if (plugInPath == null) { throw new ArgumentNullException("plugInPath"); } if (string.IsNullOrWhiteSpace(plugInPath)) { throw new ArgumentException(Resources.GOR_PARAMETER_MUST_NOT_BE_EMPTY, "plugInPath"); } plugInPath = Path.GetFullPath(plugInPath); if (string.IsNullOrWhiteSpace(plugInPath)) { throw new FileNotFoundException(); } // We can't find the plug-in assembly on the initial path, so check the path list. if (File.Exists(plugInPath)) { return(AssemblyName.GetAssemblyName(plugInPath)); } var assemblyFile = Path.GetFileName(plugInPath); plugInPath = SearchPaths.FirstOrDefault(path => File.Exists(path + assemblyFile)); if (string.IsNullOrWhiteSpace(plugInPath)) { throw new FileNotFoundException(string.Format(Resources.GOR_PLUGIN_CANNOT_FIND_FILE, assemblyFile)); } plugInPath += assemblyFile; return(AssemblyName.GetAssemblyName(plugInPath)); }
private InterpreterConfiguration(Dictionary <string, object> properties) { Id = Read(properties, nameof(Id)); _description = Read(properties, nameof(Description)) ?? ""; PrefixPath = Read(properties, nameof(PrefixPath)); InterpreterPath = Read(properties, nameof(InterpreterPath)); WindowsInterpreterPath = Read(properties, nameof(WindowsInterpreterPath)); PathEnvironmentVariable = Read(properties, nameof(PathEnvironmentVariable)); Architecture = InterpreterArchitecture.TryParse(Read(properties, nameof(Architecture))); try { Version = Version.Parse(Read(properties, nameof(Version))); } catch (ArgumentException) { Version = new Version(); } catch (FormatException) { Version = new Version(); } UIMode = 0; foreach (var bit in (Read(properties, nameof(UIMode)) ?? "").Split('|')) { InterpreterUIMode m; if (Enum.TryParse(bit, out m)) { UIMode |= m; } } if (properties.TryGetValue(nameof(SearchPaths), out object o)) { SearchPaths.Clear(); if (o is string s) { SearchPaths.AddRange(s.Split(';')); } else if (o is IEnumerable <string> ss) { SearchPaths.AddRange(ss); } } }
public InteractiveScriptGlobals(TextWriter outputWriter, ObjectFormatter objectFormatter) { if (outputWriter == null) { throw new ArgumentNullException(nameof(outputWriter)); } if (objectFormatter == null) { throw new ArgumentNullException(nameof(objectFormatter)); } Debug.Assert(outputWriter != null); Debug.Assert(objectFormatter != null); ReferencePaths = new SearchPaths(); SourcePaths = new SearchPaths(); Args = new List<string>(); PrintOptions = ObjectFormattingOptions.Default; _outputWriter = outputWriter; _objectFormatter = objectFormatter; }
public void Exceptions() { var sp = new SearchPaths(); AssertEx.Equal(new string[0], sp.List.GetNewContent()); Assert.Equal(0, sp.List.Version); Assert.Throws <ArgumentNullException>(() => sp.AddRange(null)); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(0, sp.List.Version); Assert.Throws <ArgumentNullException>(() => sp.CopyTo(null, 0)); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(0, sp.List.Version); Assert.Throws <ArgumentOutOfRangeException>(() => sp.Insert(10, "")); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(0, sp.List.Version); Assert.Throws <ArgumentOutOfRangeException>(() => sp.RemoveAt(-1)); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(0, sp.List.Version); }
public InteractiveScriptGlobals(TextWriter outputWriter, ObjectFormatter objectFormatter) { if (outputWriter == null) { throw new ArgumentNullException(nameof(outputWriter)); } if (objectFormatter == null) { throw new ArgumentNullException(nameof(objectFormatter)); } Debug.Assert(outputWriter != null); Debug.Assert(objectFormatter != null); ReferencePaths = new SearchPaths(); SourcePaths = new SearchPaths(); Args = new List <string>(); PrintOptions = ObjectFormattingOptions.Default; _outputWriter = outputWriter; _objectFormatter = objectFormatter; }
internal void WriteToDictionary(Dictionary <string, object> properties) { properties[nameof(Id)] = Id; properties[nameof(Description)] = _description; properties[nameof(PrefixPath)] = PrefixPath; properties[nameof(InterpreterPath)] = InterpreterPath; properties[nameof(WindowsInterpreterPath)] = WindowsInterpreterPath; properties[nameof(PathEnvironmentVariable)] = PathEnvironmentVariable; properties[nameof(Architecture)] = Architecture.ToString(); if (Version != null) { properties[nameof(Version)] = Version.ToString(); } var m = Enum.GetValues(typeof(InterpreterUIMode)).Cast <Enum>() .Where(flag => UIMode.HasFlag(flag)) .Select(flag => Enum.GetName(typeof(InterpreterUIMode), flag)); if (m.Any()) { properties[nameof(UIMode)] = string.Join("|", m); } properties[nameof(SearchPaths)] = SearchPaths.ToArray(); }
/// <summary> /// <para> /// Returns the list of dependent binary files for the given binary file. /// </para> /// <para> /// This function has to distinct modes of operation. If the input filename is a /// complete path, that file alone is inspected. If it is not a complete path, /// a list of candidate binary files are located among the search paths, and each of /// these will have their dependents enumerated. /// </para> /// <para> /// Inspection results for each binary file are cached, to prevent endless loop of /// recalculations. /// </para> /// </summary> /// <param name="filename"></param> /// <param name="addDirectoryToSearchPaths"></param> /// <returns> /// The list of dependent files. This list contains the pathless file names. /// To translate into full paths, see <see cref="AllFileCandidates"/>. /// </returns> public List<string> GetDependents(string filename, bool addDirectoryToSearchPaths = false) { if (addDirectoryToSearchPaths && Path.IsPathRooted(filename) && File.Exists(filename)) { SearchPaths.Add(Path.GetDirectoryName(filename)); } List<string> candidates = ResolveFilename(filename); HashSet<string> pathlessDependents = new HashSet<string>(new FilenameKeyComparer()); foreach (string candidate in candidates) { var fileInfo = new FileInfo(candidate); var fullName = fileInfo.FullName; if (DependenceRecords.ContainsKey(fullName)) { foreach (string dependent in DependenceRecords[fullName].Dependents) { pathlessDependents.Add(dependent); } continue; } var results = DumpBinProcessor.GetDependents(fullName); var record = new DependenceRecord() { StartingFilePath = fullName, Dependents = results }; DependenceRecords.Add(fullName, record); foreach (string result in results) { pathlessDependents.Add(result); } } return new List<string>(pathlessDependents); }
internal InteractiveHostObject() { ReferencePaths = new SearchPaths(); SourcePaths = new SearchPaths(); }
/// <summary> /// Enumerate local library assemblies and add them to DynamoController's /// dictionaries and search. /// </summary> internal static void LoadBuiltinTypes() { string location = GetDynamoDirectory(); #region determine assemblies to load var allLoadedAssembliesByPath = new Dictionary <string, Assembly>(); var allLoadedAssemblies = new Dictionary <string, Assembly>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { try { allLoadedAssembliesByPath[assembly.Location] = assembly; allLoadedAssemblies[assembly.FullName] = assembly; } catch { } } IEnumerable <string> allDynamoAssemblyPaths = SearchPaths.Select(path => Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly)) .Aggregate( Directory.GetFiles(location, "*.dll") as IEnumerable <string>, Enumerable.Concat); var resolver = new ResolveEventHandler(delegate(object sender, ResolveEventArgs args) { Assembly result; allLoadedAssemblies.TryGetValue(args.Name, out result); return(result); }); AppDomain.CurrentDomain.AssemblyResolve += resolver; foreach (var assemblyPath in allDynamoAssemblyPaths) { var fn = Path.GetFileName(assemblyPath); if (fn == null) { continue; } if (LoadedAssemblyNames.Contains(fn)) { continue; } LoadedAssemblyNames.Add(fn); if (allLoadedAssembliesByPath.ContainsKey(assemblyPath)) { LoadNodesFromAssembly(allLoadedAssembliesByPath[assemblyPath]); } else { try { var assembly = Assembly.LoadFrom(assemblyPath); allLoadedAssemblies[assembly.GetName().Name] = assembly; LoadNodesFromAssembly(assembly); } catch (BadImageFormatException) { //swallow these warnings. } catch (Exception e) { dynSettings.Controller.DynamoLogger.Log(e); } } } #if USE_DSENGINE dynSettings.Controller.SearchViewModel.Add(dynSettings.Controller.EngineController.GetFunctionGroups()); #endif AppDomain.CurrentDomain.AssemblyResolve -= resolver; #endregion }
/// <summary> /// Load all types which inherit from NodeModel whose assemblies are located in /// the bin/nodes directory. Add the types to the searchviewmodel and /// the controller's dictionaries. /// </summary> internal static void LoadNodeModels() { string location = Path.Combine(GetDynamoDirectory(), "nodes"); var allLoadedAssembliesByPath = new Dictionary <string, Assembly>(); var allLoadedAssemblies = new Dictionary <string, Assembly>(); // cache the loaded assembly information foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { try { allLoadedAssembliesByPath[assembly.Location] = assembly; allLoadedAssemblies[assembly.FullName] = assembly; } catch { } } // find all the dlls registered in all search paths // and concatenate with all dlls in the current directory List <string> allDynamoAssemblyPaths = SearchPaths.Select(path => Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly)) .Aggregate( Directory.GetFiles(location, "*.dll") as IEnumerable <string>, Enumerable.Concat).ToList(); // add the core assembly to get things like code block nodes and watches. allDynamoAssemblyPaths.Add(Path.Combine(GetDynamoDirectory(), "DynamoCore.dll")); var resolver = new ResolveEventHandler(delegate(object sender, ResolveEventArgs args) { Assembly result; allLoadedAssemblies.TryGetValue(args.Name, out result); return(result); }); AppDomain.CurrentDomain.AssemblyResolve += resolver; foreach (var assemblyPath in allDynamoAssemblyPaths) { var fn = Path.GetFileName(assemblyPath); if (fn == null) { continue; } // if the assembly has already been loaded, then // skip it, otherwise cache it. if (LoadedAssemblyNames.Contains(fn)) { continue; } LoadedAssemblyNames.Add(fn); if (allLoadedAssembliesByPath.ContainsKey(assemblyPath)) { LoadNodesFromAssembly(allLoadedAssembliesByPath[assemblyPath]); } else { try { var assembly = Assembly.LoadFrom(assemblyPath); allLoadedAssemblies[assembly.GetName().Name] = assembly; LoadNodesFromAssembly(assembly); } catch (BadImageFormatException) { //swallow these warnings. } catch (Exception e) { dynSettings.Controller.DynamoLogger.Log(e); } } } dynSettings.Controller.SearchViewModel.Add(dynSettings.Controller.EngineController.GetFunctionGroups()); AppDomain.CurrentDomain.AssemblyResolve -= resolver; }
public void ListOperations() { var sp = new SearchPaths(); AssertEx.Equal(Array.Empty<string>(), sp.List.GetNewContent()); Assert.Equal(0, sp.List.Version); sp.Add("foo"); AssertEx.Equal(new[] { "foo" }, sp.List.GetNewContent()); Assert.Equal(1, sp.List.Version); sp.AddRange(new[] { "bar" }); AssertEx.Equal(new[] { "foo", "bar" }, sp.List.GetNewContent()); Assert.Equal(2, sp.List.Version); sp.AddRange(new[] { "baz" }); AssertEx.Equal(new[] { "foo", "bar", "baz" }, sp.List.GetNewContent()); Assert.Equal(3, sp.List.Version); Assert.True(sp.Contains("bar")); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(3, sp.List.Version); var a = new string[sp.Count + 2]; Assert.Equal(3, sp.List.Version); AssertEx.Equal(null, sp.List.GetNewContent()); sp.CopyTo(a, 1); AssertEx.Equal(new[] { null, "foo", "bar", "baz", null }, a); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(3, sp.List.Version); AssertEx.Equal(new[] { "foo", "bar", "baz" }, sp); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(3, sp.List.Version); Assert.Equal(2, sp.IndexOf("baz")); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(3, sp.List.Version); sp.Insert(1, "goo"); AssertEx.Equal(new[] { "foo", "goo", "bar", "baz" }, sp); AssertEx.Equal(new[] { "foo", "goo", "bar", "baz" }, sp.List.GetNewContent()); Assert.Equal(4, sp.List.Version); Assert.False(sp.IsReadOnly); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(4, sp.List.Version); Assert.True(sp.Remove("bar")); Assert.Equal(5, sp.List.Version); AssertEx.Equal(new[] { "foo", "goo", "baz" }, sp); AssertEx.Equal(new[] { "foo", "goo", "baz" }, sp.List.GetNewContent()); Assert.False(sp.Remove("___")); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(5, sp.List.Version); sp.RemoveAt(1); AssertEx.Equal(new[] { "foo", "baz" }, sp); AssertEx.Equal(new[] { "foo", "baz" }, sp.List.GetNewContent()); Assert.Equal(6, sp.List.Version); sp.Clear(); AssertEx.Equal(Array.Empty<string>(), sp.List.GetNewContent()); Assert.Equal(7, sp.List.Version); sp.Clear(); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(7, sp.List.Version); }
public void Exceptions() { var sp = new SearchPaths(); AssertEx.Equal(Array.Empty<string>(), sp.List.GetNewContent()); Assert.Equal(0, sp.List.Version); Assert.Throws<ArgumentNullException>(() => sp.AddRange(null)); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(0, sp.List.Version); Assert.Throws<ArgumentNullException>(() => sp.CopyTo(null, 0)); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(0, sp.List.Version); Assert.Throws<ArgumentOutOfRangeException>(() => sp.Insert(10, "")); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(0, sp.List.Version); Assert.Throws<ArgumentOutOfRangeException>(() => sp.RemoveAt(-1)); AssertEx.Equal(null, sp.List.GetNewContent()); Assert.Equal(0, sp.List.Version); }