Esempio n. 1
0
        /// <summary>
        /// Adds the specified .dll file to the FoundUserPluginFiles list if it is a valid .net assembly. If a plugin file already exists at the specified path, it will be replaced.
        /// </summary>
        /// <param name="path">The full path to the file.</param>
        /// <returns>True if the plugin file was added, false if otherwise.</returns>
        private static bool TryAddUserFileDLL(string path)
        {
            List <PluginFile> existing = FoundUserPluginFiles.Where(x => PathsAreEqual(path, x.PathToFile)).ToList();

            foreach (PluginFile pluginFile in existing)
            {
                FoundUserPluginFiles.Remove(pluginFile);
            }

            // Check if the DLL is a valid .NET assembly
            bool valid = false;

            try
            {
                AssemblyName asmName = AssemblyName.GetAssemblyName(path);
                valid = true;
            }
            catch (Exception e) { }

            if (valid)
            {
                PluginFile newPluginFile = new PluginFile(path, PluginFileType.CompiledAssemblyFile);
                FoundUserPluginFiles.Add(newPluginFile);
                OnUserPluginFileAdded(new UserPluginFileEventArgs(path, newPluginFile));
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Adds the specified .cs file to the FoundUserPluginFiles list if it is valid. If a plugin file already exists at the specified path, it will be replaced.
        /// </summary>
        /// <param name="path">The full path to the file.</param>
        /// <returns>True if the plugin file was added, false if otherwise.</returns>
        private static bool TryAddUserFileCS(string path)
        {
            List <PluginFile> existing = FoundUserPluginFiles.Where(x => PathsAreEqual(path, x.PathToFile)).ToList();

            foreach (PluginFile pluginFile in existing)
            {
                FoundUserPluginFiles.Remove(pluginFile);
            }

            // In this case, there is no file contents checking (for now)
            PluginFile newPluginFile = new PluginFile(path, PluginFileType.CSSourceFile);

            FoundUserPluginFiles.Add(newPluginFile);
            OnUserPluginFileAdded(new UserPluginFileEventArgs(path, newPluginFile));
            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Removes the specified file from the FoundUserPluginFiles list if it is valid.
        /// </summary>
        /// <param name="path">The full path to the file.</param>
        /// <returns>True if the plugin file was removed, false if otherwise.</returns>
        private static bool TryRemoveUserFile(string path)
        {
            PluginFile toRemove = null;

            foreach (PluginFile pluginFile in FoundUserPluginFiles)
            {
                if (PathsAreEqual(path, pluginFile.PathToFile))
                {
                    toRemove = pluginFile;
                    break;
                }
            }
            if (toRemove != null)
            {
                FoundUserPluginFiles.Remove(toRemove);
                OnUserPluginFileRemoved(new UserPluginFileEventArgs(toRemove.PathToFile, toRemove));
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Creates a new SecurityLevelComplianceSingleTestResult for the specified PluginFile.
 /// </summary>
 /// <param name="pluginFileToTest">The PluginFile to associate with these test results.</param>
 public SecurityLevelComplianceSingleTestResult(PluginFile pluginFileToTest)
 {
     TestedPluginFile = pluginFileToTest;
 }
Esempio n. 5
0
 public UserPluginFileEventArgs(string path, PluginFile pluginFile)
 {
     FilePath           = path;
     AffectedPluginFile = pluginFile;
 }
Esempio n. 6
0
 /// <summary>
 /// Returns the temporary folder path to use for reading and writing temporary, on-disk files relating to the specific PluginFile.
 /// </summary>
 /// <param name="pluginFile">The PluginFile whose PathToFile will be used.</param>
 /// <returns>The path to the directory to use. The directory will NOT be created if it does not exist.</returns>
 public static string GetTemporaryFilePathFor(PluginFile pluginFile)
 {
     return(Path.Combine(PluginsTempFilesFolder, pluginFile.GetRelativePath()));
 }
Esempio n. 7
0
 public UserPluginFileRenamedEventArgs(string oldPath, string newPath, PluginFile pluginFile)
 {
     OldFilePath        = oldPath;
     NewFilePath        = newPath;
     AffectedPluginFile = pluginFile;
 }