Plugin.cs

Description du code

Plugin.cs est un fichier du projet BrolDev.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/broldev/src/.

Projet BrolDev : Librairie de composants réutilisables pour les applications BrolDev en CSharp.

Code source ou contenu du fichier

  1. using System;
  2. using System.IO;
  3. using System.Reflection;
  4. using System.Windows.Forms;
  5.  
  6. namespace be.gaudry.model.config
  7. {
  8. public class Plugin
  9. {
  10. private String fullPath, name, version, description;
  11.  
  12. public Plugin(String directory, String name)
  13. {
  14. if (String.Empty.Equals(directory))
  15. directory = Application.StartupPath;
  16.  
  17. this.fullPath = String.Format(
  18. "{0}{1}{2}",
  19. directory,
  20. Path.DirectorySeparatorChar,
  21. name
  22. );
  23.  
  24. if (File.Exists(fullPath))
  25. {
  26. Assembly assembly = Assembly.LoadFile(fullPath);
  27. this.name = getName(assembly);
  28. this.version = getVersion(assembly);
  29. this.description = getDescription(assembly);
  30. }
  31. else
  32. {
  33. this.name = "Inconnu";
  34. this.version = "Inconnue";
  35. this.description = "";
  36. }
  37. }
  38.  
  39. private String getDescription(Assembly assembly)
  40. {
  41. // Get all Description properties on this assembly
  42. object[] properties = assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
  43. // If there aren't any Description properties, return an empty string
  44. if (properties.Length == 0)
  45. return "";
  46. // If there is a Description attribute, return its value
  47. return ((AssemblyDescriptionAttribute)properties[0]).Description;
  48. }
  49.  
  50. private String getVersion(Assembly assembly)
  51. {
  52. return assembly.GetName().Version.ToString();
  53. }
  54.  
  55. private String getName(Assembly assembly)
  56. {
  57. // Get all Title properties on this assembly
  58. object[] properties = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
  59. // If there is at least one Title attribute
  60. if (properties.Length > 0)
  61. {
  62. // Select the first one
  63. AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)properties[0];
  64. // If it is not an empty string, return it
  65. if (titleAttribute.Title != "")
  66. return titleAttribute.Title;
  67. }
  68. // If there was no Title attribute, or if the Title attribute was the empty string, return the .exe name
  69. return Path.GetFileNameWithoutExtension(assembly.CodeBase);
  70. }
  71. public String Name
  72. {
  73. get { return this.name; }
  74. }
  75. public String Version
  76. {
  77. get { return this.version; }
  78. }
  79. public String Description
  80. {
  81. get { return this.description; }
  82. }
  83.  
  84. #region overrided methods
  85. public override String ToString()
  86. {
  87. return name;
  88. }
  89. public override int GetHashCode()
  90. {
  91. return fullPath.GetHashCode();
  92. }
  93. public override bool Equals(Object o)
  94. {
  95. if (this == o) return true;
  96. if (!(o is Plugin)) return false;
  97. Plugin p = (Plugin)o;
  98. return p.fullPath.Equals(this.fullPath);
  99. }
  100. #endregion
  101. }
  102. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/model/config/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1714870449 05/05/2024 02:54:09
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/model/config/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csPluginsManager.cs3.8 Ko31/10/2018 18:33:08-refusé-
Afficher le fichier .cs|.csSource.cs2.8 Ko31/10/2018 18:33:08-refusé-
Afficher le fichier .cs|.csSettings.cs6.91 Ko31/10/2018 18:33:08-refusé-
Afficher le fichier .cs|.csPlugin.cs3.36 Ko31/10/2018 18:33:08-refusé-
Afficher le fichier .cs|.csSourcesManager.cs1.38 Ko31/10/2018 18:33:08-refusé-

Utilisation de l'explorateur de code

  • Navigation :
    • Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
    • Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
    • La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
    • Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
  • Affichage :
    • Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
  • Actions :
    • Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.

Document créé le 16/10/2009, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/cs-broldev-source-rf-model/config/Plugin.cs.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.