/// <summary>
 /// Initializes a new s_instance of the <see cref="CompositeComponentMetadataDefinition"/> class.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="componentSourceFile">The component source file.</param>
 /// <param name="componentName">Name of the component.</param>
 /// <param name="label">The label.</param>
 /// <param name="version">The version.</param>
 /// <param name="description">The description.</param>
 /// <param name="author">The author.</param>
 public CompositeComponentMetadataDefinition(string id,
                                             TraceLab.Core.Experiments.CompositeComponentGraph componentGraph,
                                             string componentSourceFile, string componentName, string label, string version, string description, string author,
                                             ComponentTags tags, List <DocumentationLink> documentationLinks)
     : base(id, componentSourceFile, componentName, label, version, description, author, tags, documentationLinks)
 {
     ComponentGraph   = componentGraph;
     IOSpecDefinition = new IOSpecDefinition();
     ConfigurationWrapperDefinition = new ConfigWrapperDefinition(false, null);
 }
Пример #2
0
        public ComponentTags GetUserTags()
        {
            var tags = new ComponentTags(m_componentDefinitionId);

            foreach (TagValue value in m_values)
            {
                if (value.IsUserTag)
                {
                    tags.m_values.Add(value);
                }
            }

            return(tags);
        }
Пример #3
0
        public void ApplyOverrides(ComponentTags overrides)
        {
            if (overrides == null)
            {
                throw new ArgumentNullException("overrides");
            }
            if (string.Equals(overrides.ComponentDefinitionId, this.ComponentDefinitionId, StringComparison.CurrentCultureIgnoreCase) == false)
            {
                throw new ArgumentException("Cannot provide overrides from another component.", "overrides");
            }

            foreach (TagValue value in overrides.m_values)
            {
                SetTag(value.GetCookedValue(), value.IsUserTag);
            }
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataDefinition"/> class.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="assembly">The assembly.</param>
        /// <param name="classname">The classname.</param>
        /// <param name="label">The label.</param>
        /// <param name="version">The version.</param>
        /// <param name="description">The description.</param>
        /// <param name="author">The author.</param>
        /// <param name="tags">The tags.</param>
        protected MetadataDefinition(string id, string assembly, string classname, string label, string version, string description, string author,
                                     ComponentTags tags, List <DocumentationLink> documentationLinks)
            : this(id, assembly, classname)
        {
            Version     = version;
            Label       = label;
            Description = description;
            Author      = author;
            ID          = id;
            Assembly    = assembly;
            Classname   = classname;
            Tags        = tags;

            documentationLinks.Sort(DocumentationLink.SortLinksByOrderComparer);
            m_documentationLinks = documentationLinks;
        }
        public void ReadXml(System.Xml.XmlReader reader)
        {
            int version = int.Parse(reader.GetAttribute("xmlVersion"));

            if (version != xmlVersion && version != 1)
            {
                throw new InvalidOperationException("Version file not recognized");
            }

            XPathDocument  doc = new XPathDocument(reader);
            XPathNavigator nav = doc.CreateNavigator();

            XPathNavigator iter = ReadComponentInfo(nav);

            if (version == xmlVersion)
            {
                ReadCurrentVersionIODefinitions(nav);
            }
            else if (version == 1)
            {
                ReadOldIODefinitions(nav);
            }

            iter = nav.SelectSingleNode("/CompositeComponentMetadataDefinition/ConfigDefinition");
            ConfigurationWrapperDefinition.ReadXml(iter.ReadSubtree());

            //get experiment xml -> reading this xml is done in PostProcessReadXml
            iter            = nav.SelectSingleNode("/CompositeComponentMetadataDefinition/ComponentGraph");
            m_experimentXml = iter.InnerXml;

            //read tags
            Tags = new ComponentTags(ID);

            XPathNodeIterator tagsIterator = nav.Select("/CompositeComponentMetadataDefinition/Tags//Tag");

            while (tagsIterator.MoveNext())
            {
                string tagValue = tagsIterator.Current.Value;
                Tags.SetTag(tagValue, false);
            }
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DecisionMetadataDefinition"/> class.
 /// </summary>
 /// <param name="id">The id.</param>
 public DecisionMetadataDefinition(string id) : base(id)
 {
     Tags = new ComponentTags(id);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommentMetadataDefinition"/> class.
 /// </summary>
 /// <param name="id">The id.</param>
 public CommentMetadataDefinition(string id)
     : base(id)
 {
     Tags = new ComponentTags(id);
 }
Пример #8
0
        /// <summary>
        /// Checks the type for existence of Component Attribute. If type has Component Attribute it creates
        /// component metadata definition and adds it to the assembly file descriptor.
        /// If Component Attribute was found, but was in incorrect format error is reported.
        /// </summary>
        /// <param name="assemblyPath">The assembly path.</param>
        /// <param name="exportedType">Type of the exported.</param>
        /// <param name="assemblyFile">The assembly file.</param>
        private void CheckType(string assemblyPath, Type exportedType, AssemblyFileDescriptor assemblyFile)
        {
            var attribs = exportedType.GetCustomAttributes(typeof(ComponentAttribute), false);

            if (attribs.Length == 1)
            {
                try
                {
                    var attrib           = (ComponentAttribute)attribs[0];
                    var ioSpecDefinition = ComponentScannerHelper.ReadIOSpec(exportedType);
                    var configurationWrapperDefinition = ComponentScannerHelper.CreateConfigWrapperDefinition(attrib.ConfigurationType);
                    var componentId = ComponentScannerHelper.CreateComponentId(attrib.Name, ioSpecDefinition, attrib.Version, configurationWrapperDefinition);

                    ComponentTags tags       = new ComponentTags(componentId);
                    var           tagAttribs = exportedType.GetCustomAttributes(typeof(TagAttribute), false);
                    foreach (TagAttribute tag in tagAttribs)
                    {
                        tags.SetTag(tag.Tag, false);
                    }

                    //name participates in guid generation, and is assign as default label, unless other default label has been specified
                    string defaultLabel = (String.IsNullOrWhiteSpace(attrib.DefaultLabel)) ? attrib.Name : attrib.DefaultLabel;

                    //gather all documentation links
                    List <DocumentationLink> documentationLinks = new List <DocumentationLink>();
                    var linkAttribs = exportedType.GetCustomAttributes(typeof(LinkAttribute), false);
                    foreach (LinkAttribute link in linkAttribs)
                    {
                        Uri url;
                        if (Uri.TryCreate(link.Url, UriKind.Absolute, out url))
                        {
                            documentationLinks.Add(new DocumentationLink(url, link.Title, link.Description, link.Order));
                        }
                        else
                        {
                            NLog.LogManager.GetCurrentClassLogger().Warn(
                                String.Format("Documentation link url '{0}' for component '{1}' could not be processed correctly and has been ommitted", link.Url, defaultLabel));
                        }
                    }

                    var compDef = new ComponentMetadataDefinition(componentId,
                                                                  assemblyPath,
                                                                  exportedType.FullName,
                                                                  ioSpecDefinition,
                                                                  defaultLabel,
                                                                  attrib.Version,
                                                                  attrib.Description,
                                                                  attrib.Author,
                                                                  attrib.IsJava ? Language.JAVA : Language.NET,
                                                                  configurationWrapperDefinition,
                                                                  tags,
                                                                  documentationLinks);

                    assemblyFile.MetadataCollection.Add(compDef);

                    //if old manual guid has been set, add it to the map from new autogenerated guid to old guid
                    if (attrib.GuidIDString != null && attrib.GuidID != null)
                    {
                        string oldGuidID = attrib.GuidID.ToString();
                        if (!assemblyFile.NewGuidToOldGuid.ContainsValue(oldGuidID))
                        {
                            assemblyFile.NewGuidToOldGuid.Add(componentId, oldGuidID);
                        }
                    }
                }
                catch (Exceptions.ComponentsLibraryException ex)
                {
                    Errors.Add(String.Format("Potential component type {0} located in assembly {1} has invalid ComponentAttribute: {2}", exportedType, assemblyPath, ex.Message));
                }
            }
            else if (1 < attribs.Length)
            {
                var errorMsg = "ERROR: Somehow there are more than one ComponentAttribute instances on type " + exportedType.FullName;
                Errors.Add(errorMsg);
            }
        }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChallengeMetadataDefinition"/> class.
 /// </summary>
 /// <param name="id">The id.</param>
 public ChallengeMetadataDefinition(string id)
     : base(id)
 {
     Tags = new ComponentTags(id);
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentMetadataDefinition"/> class.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="assembly">The assembly.</param>
 /// <param name="classname">The classname.</param>
 /// <param name="iospec">The iospec.</param>
 /// <param name="label">The label.</param>
 /// <param name="version">The version.</param>
 /// <param name="description">The description.</param>
 /// <param name="author">The author.</param>
 /// <param name="language">The language.</param>
 /// <param name="configurationDefinition">The configuration definition.</param>
 /// <param name="tags">The tags.</param>
 public ComponentMetadataDefinition(string id, string assembly, string classname, IOSpecDefinition iospec,
                                    string label, string version, string description, string author, Language language,
                                    ConfigWrapperDefinition configurationDefinition, ComponentTags tags, List <DocumentationLink> documentationLinks)
     : base(id, assembly, classname, label, version, description, author, tags, documentationLinks)
 {
     Language         = language;
     IOSpecDefinition = iospec;
     if (configurationDefinition != null)
     {
         ConfigurationWrapperDefinition = configurationDefinition;
         ConfigurationType = configurationDefinition.ConfigurationTypeFullName;
     }
 }