Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/11/10 13:04:42 (15 years ago)
Author:
gkronber
Message:

Implemented ContactInformationAttribute. #868 (Attribute to declare contact information details for plugins)

Location:
trunk/sources/HeuristicLab.PluginInfrastructure
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/InstallationManager.cs

    r2763 r2778  
    7171      builder.Append("Version: ").AppendLine(desc.Version.ToString());
    7272      builder.AppendLine("Description:").AppendLine(desc.Description);
     73      if (!string.IsNullOrEmpty(desc.ContactName)) {
     74        builder.Append("Contact: ").Append(desc.ContactName).Append(", ").AppendLine(desc.ContactEmail);
     75      }
    7376      builder.AppendLine("This plugin is " + desc.PluginState.ToString().ToLowerInvariant() + ".");
    74       builder.Append("Build date: ").AppendLine(desc.BuildDate.ToString()).AppendLine();
     77      // builder.Append("Build date: ").AppendLine(desc.BuildDate.ToString()).AppendLine();
    7578      builder.AppendLine("Files: ");
    7679      foreach (var file in desc.Files) {
  • trunk/sources/HeuristicLab.PluginInfrastructure/HeuristicLab.PluginInfrastructure.csproj

    r2748 r2778  
    102102    <Compile Include="Attributes\ApplicationAttribute.cs" />
    103103    <Compile Include="Attributes\AssemblyBuildDateAttribute.cs" />
     104    <Compile Include="Attributes\ContactInformationAttribute.cs" />
    104105    <Compile Include="Attributes\PluginAttribute.cs" />
    105106    <Compile Include="Attributes\PluginDependencyAttribute.cs" />
  • trunk/sources/HeuristicLab.PluginInfrastructure/Interfaces/IPluginDescription.cs

    r2688 r2778  
    3939    /// Gets the build date of the plugin.
    4040    /// </summary>
     41    [Obsolete]
    4142    DateTime BuildDate { get; }
    4243    /// <summary>
  • trunk/sources/HeuristicLab.PluginInfrastructure/Manager/PluginDescription.cs

    r2763 r2778  
    6969      get { return buildDate; }
    7070      internal set { buildDate = value; }
     71    }
     72
     73    private string contactName;
     74    /// <summary>
     75    /// Gets or sets the name of the contact person for this plugin.
     76    /// </summary>
     77    internal string ContactName {
     78      get { return contactName; }
     79      set { contactName = value; }
     80    }
     81
     82    private string contactEmail;
     83    /// <summary>
     84    /// Gets or sets the e-mail address of the contact person for this plugin.
     85    /// </summary>
     86    internal string ContactEmail {
     87      get { return contactEmail; }
     88      set { contactEmail = value; }
    7189    }
    7290
  • trunk/sources/HeuristicLab.PluginInfrastructure/Manager/PluginValidator.cs

    r2763 r2778  
    262262
    263263      string pluginName, pluginDescription, pluginVersion;
     264      string contactName, contactAddress;
    264265      GetPluginMetaData(pluginType, out pluginName, out pluginDescription, out pluginVersion);
     266      GetPluginContactMetaData(pluginType, out contactName, out contactAddress);
    265267      var pluginFiles = GetPluginFilesMetaData(pluginType);
    266268      var pluginDependencies = GetPluginDependencyMetaData(pluginType);
     
    268270      // minimal sanity check of the attribute values
    269271      if (!string.IsNullOrEmpty(pluginName) &&
    270           pluginFiles.Count() > 0 &&                                 // at least on file
    271           pluginFiles.Any(f => f.Type == PluginFileType.Assembly)) { // at least on assembly
     272          pluginFiles.Count() > 0 &&                                 // at least one file
     273          pluginFiles.Any(f => f.Type == PluginFileType.Assembly)) { // at least one assembly
    272274        // create a temporary PluginDescription that contains the attribute values
    273275        PluginDescription info = new PluginDescription();
     
    275277        info.Description = pluginDescription;
    276278        info.Version = new Version(pluginVersion);
     279        info.ContactName = contactName;
     280        info.ContactEmail = contactAddress;
    277281        info.AddFiles(pluginFiles);
    278282
     
    305309        }
    306310        yield return new PluginDependency(name, version);
     311      }
     312    }
     313
     314    private static void GetPluginContactMetaData(Type pluginType, out string contactName, out string contactAddress) {
     315      // get attribute of type ContactInformation if there is any
     316      var contactInfoAttribute = (from attr in CustomAttributeData.GetCustomAttributes(pluginType)
     317                                  where IsAttributeDataForType(attr, typeof(ContactInformationAttribute))
     318                                  select attr).SingleOrDefault();
     319
     320      if (contactInfoAttribute != null) {
     321        contactName = (string)contactInfoAttribute.ConstructorArguments[0].Value;
     322        contactAddress = (string)contactInfoAttribute.ConstructorArguments[1].Value;
     323      } else {
     324        contactName = string.Empty;
     325        contactAddress = string.Empty;
    307326      }
    308327    }
Note: See TracChangeset for help on using the changeset viewer.