/// <summary> /// Initializes a new instance of <see cref="PluginFileAttribute"/>. /// <param name="fileName">Name of the file</param> /// <param name="fileType">Type of the file (Assembly, NativeDll, Data, License)</param> /// </summary> public PluginFileAttribute(string fileName, PluginFileType fileType) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentException("File name is empty.", "fileName"); } // NB: doesn't check if the file actually exists this.fileName = fileName; this.fileType = fileType; }
// not static because we need the PluginDir property private IEnumerable <PluginFile> GetPluginFilesMetaData(Type pluginType) { // get all attributes of type PluginFileAttribute var pluginFileAttributes = from attr in CustomAttributeData.GetCustomAttributes(pluginType) where IsAttributeDataForType(attr, typeof(PluginFileAttribute)) select attr; foreach (var pluginFileAttribute in pluginFileAttributes) { string pluginFileName = (string)pluginFileAttribute.ConstructorArguments[0].Value; PluginFileType fileType = (PluginFileType)pluginFileAttribute.ConstructorArguments[1].Value; yield return(new PluginFile(Path.GetFullPath(Path.Combine(PluginDir, pluginFileName)), fileType)); } }
/// <summary> /// Update this PluginFile's PathToFile and FileType to correspond to a new path. /// </summary> /// <param name="newPath">The new path to use.</param> public void UpdateFilePath(string newPath) { PathToFile = newPath; string newExt = Path.GetExtension(Path.GetFullPath(newPath)).ToLowerInvariant(); if (newExt == ".cs") { FileType = PluginFileType.CSSourceFile; } else if (newExt == ".dll") { FileType = PluginFileType.CompiledAssemblyFile; } }
/// <summary> /// Creates a new PluginFile object for use in plugin file management. /// </summary> /// <param name="path">Path to the file on the disk.</param> /// <param name="type">What kind of file the plugin is.</param> public PluginFile(string path, PluginFileType type) { PathToFile = path; FileType = type; }
/// <summary> /// Inizialize a new instance of <see cref="PluginFile" /> /// </summary> /// <param name="name">File name</param> /// <param name="type">File type</param> public PluginFile(string name, PluginFileType type) { this.name = name; this.type = type; }
/// <summary> /// Initializes a new instance of <see cref="PluginFileAttribute"/>. /// <param name="fileName">Name of the file</param> /// <param name="fileType">Type of the file (Assembly, NativeDll, Data, License)</param> /// </summary> public PluginFileAttribute(string fileName, PluginFileType fileType) { if (string.IsNullOrEmpty(fileName)) throw new ArgumentException("File name is empty.", "fileName"); // NB: doesn't check if the file actually exists this.fileName = fileName; this.fileType = fileType; }