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/Manager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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.