public void ApplyOverridesTest() { string definitionId = Guid.NewGuid().ToString(); ComponentTags baseTag = new ComponentTags(definitionId); List <string> tags = new List <string>(new string[] { "+Test", "+Foo", "+Bar" }); foreach (string tag in tags) { baseTag.SetTag(tag, false); } ComponentTags overrideTag = new ComponentTags(definitionId); List <string> overrideTags = new List <string>(new string[] { "+AnotherTestValue", "+Foo", "-Foo" }); foreach (string tag in overrideTags) { overrideTag.SetTag(tag, false); } baseTag.ApplyOverrides(overrideTag); Assert.AreEqual(3, baseTag.Values.Count); Assert.IsTrue(baseTag.Values.Contains("Test")); Assert.IsTrue(baseTag.Values.Contains("Bar")); Assert.IsTrue(baseTag.Values.Contains("AnotherTestValue")); Assert.IsFalse(baseTag.Values.Contains("Foo")); }
public void ComponentTagsConstructorTest() { string definitionId = Guid.NewGuid().ToString(); ComponentTags target = new ComponentTags(definitionId); Assert.AreEqual(definitionId, target.ComponentDefinitionId); Assert.AreEqual(0, target.Values.Count); }
/// <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); }
/// <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; } }
/// <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 SetTagTest() { string definitionId = Guid.NewGuid().ToString(); ComponentTags target = new ComponentTags(definitionId); string tag = "+Test"; bool isUserTag = false; target.SetTag(tag, isUserTag); Assert.AreEqual(1, target.Values.Count); Assert.AreEqual("Test", target.Values[0]); target.SetTag("-Test", false); Assert.AreEqual(0, target.Values.Count); target.SetTag("-Test", false); Assert.AreEqual(0, target.Values.Count); }
/// <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> /// 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); } }
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); } }
/// <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); }
public void ApplyOverridesTest() { string definitionId = Guid.NewGuid().ToString(); ComponentTags baseTag = new ComponentTags(definitionId); List<string> tags = new List<string>(new string[]{"+Test", "+Foo", "+Bar"}); foreach(string tag in tags) { baseTag.SetTag(tag, false); } ComponentTags overrideTag = new ComponentTags(definitionId); List<string> overrideTags = new List<string>(new string[] { "+AnotherTestValue", "+Foo", "-Foo" }); foreach (string tag in overrideTags) { overrideTag.SetTag(tag, false); } baseTag.ApplyOverrides(overrideTag); Assert.AreEqual(3, baseTag.Values.Count); Assert.IsTrue(baseTag.Values.Contains("Test")); Assert.IsTrue(baseTag.Values.Contains("Bar")); Assert.IsTrue(baseTag.Values.Contains("AnotherTestValue")); Assert.IsFalse(baseTag.Values.Contains("Foo")); }
/// <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); }