/// <summary> /// Creates the ID for the component based on its name, io spec, version, and configuration parameters. /// </summary> /// <param name="componentName">Name of the component.</param> /// <param name="componentIOSpec">The component IO spec.</param> /// <param name="version">The version.</param> /// <param name="componentConfiguration">The component configuration.</param> /// <returns>Id that represents the component</returns> public static string CreateComponentId(string componentName, IOSpecDefinition componentIOSpec, string version, ConfigWrapperDefinition componentConfiguration) { if (componentName == null) throw new Exceptions.ComponentsLibraryException("Component name is required to generate component id."); StringBuilder componentInfo = new StringBuilder(); //changes in name and version are included in guid creation componentInfo.Append(componentName); componentInfo.Append(version); //changes in iospec are included in guid creation if (componentIOSpec != null) { var inputlist = new List<string>(); foreach (KeyValuePair<string, IOItemDefinition> pair in componentIOSpec.Input) { inputlist.Add(pair.Key + pair.Value.Type); } inputlist.Sort(); var outputlist = new List<string>(); foreach (KeyValuePair<string, IOItemDefinition> pair in componentIOSpec.Output) { outputlist.Add(pair.Key + pair.Value.Type); } outputlist.Sort(); foreach(string itemString in inputlist) { componentInfo.Append(itemString); } foreach (string itemString in outputlist) { componentInfo.Append(itemString); } } //changes in configuration are included in guid creation if (componentConfiguration != null) { var configList = new List<string>(); foreach (KeyValuePair<string, ConfigPropertyObject> pair in componentConfiguration.Properties) { configList.Add(pair.Key + pair.Value.Type); } configList.Sort(); componentInfo.Append(componentConfiguration.ConfigurationTypeFullName); foreach (string configItemString in configList) { componentInfo.Append(configItemString); } } Guid id = GuidUtility.Create(GuidUtility.TraceLabNamespace, componentInfo.ToString()); return id.ToString(); }
/// <summary> /// Reads the IO spec attributes and creates iospec definition /// </summary> /// <param name="componentType">Type of the component.</param> /// <exception cref="ComponentsLibraryException">throws components exception if there are two same inputs or outputs of the same name /// added to io spec defnition</exception> /// <returns>IOSpecDefinition if there were no errors</returns> internal static IOSpecDefinition ReadIOSpec(Type componentType) { var spec = new IOSpecDefinition(); object[] inputMapping = componentType.GetCustomAttributes(typeof(IOSpecAttribute), true); if (inputMapping.Length != 0) { foreach (IOSpecAttribute attrib in inputMapping) { if (attrib.IOType == IOSpecType.Input) { if (spec.Input.ContainsKey(attrib.Name)) { throw new ComponentsLibraryException(String.Format("There cannot be multiple input attributes of the same name '{0}'", attrib.Name)); } spec.Input.Add(attrib.Name, new IOItemDefinition(attrib.Name, attrib.DataType.FullName, attrib.Description, IOSpecType.Input)); } else if (attrib.IOType == IOSpecType.Output) { if (spec.Output.ContainsKey(attrib.Name)) { throw new ComponentsLibraryException(String.Format("There cannot be multiple output attributes of the same name '{0}'", attrib.Name)); } spec.Output.Add(attrib.Name, new IOItemDefinition(attrib.Name, attrib.DataType.FullName, attrib.Description, IOSpecType.Output)); } else { throw new ComponentsLibraryException("IOSpecType enumeration is invalid"); } } } return(spec); }
private void BuildOutputDictionary(IOSpecDefinition iOSpec) { Output.Clear(); foreach (IOItemDefinition itemDefinition in iOSpec.Output.Values) { var item = new IOItem(itemDefinition, itemDefinition.Name); Output.Add(itemDefinition.Name, item); } }
/// <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 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="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> /// Determines whether the specified <see cref="System.Object"/> is equal to this instance. /// </summary> /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>. /// </returns> public override bool Equals(object obj) { IOSpecDefinition other = obj as IOSpecDefinition; if (other == null) { return(false); } bool isEqual = true; isEqual &= CollectionsHelper.DictionaryContentEquals <string, IOItemDefinition>(Output, other.Output); isEqual &= CollectionsHelper.DictionaryContentEquals <string, IOItemDefinition>(Input, other.Input); return(isEqual); }
public static string CreateComponentIdNoSortingOld(string componentName, IOSpecDefinition componentIOSpec, string version, ConfigWrapperDefinition componentConfiguration) { if (componentName == null) { throw new Exceptions.ComponentsLibraryException("Component name is required to generate component id."); } StringBuilder componentInfo = new StringBuilder(); //changes in name and version are included in guid creation componentInfo.Append(componentName); componentInfo.Append(version); //changes in iospec are included in guid creation if (componentIOSpec != null) { foreach (KeyValuePair <string, IOItemDefinition> pair in componentIOSpec.Input) { componentInfo.Append(pair.Key); componentInfo.Append(pair.Value.Type); } foreach (KeyValuePair <string, IOItemDefinition> pair in componentIOSpec.Output) { componentInfo.Append(pair.Key); componentInfo.Append(pair.Value.Type); } } //changes in configuration are included in guid creation if (componentConfiguration != null) { componentInfo.Append(componentConfiguration.ConfigurationTypeFullName); foreach (KeyValuePair <string, ConfigPropertyObject> pair in componentConfiguration.Properties) { componentInfo.Append(pair.Key); componentInfo.Append(pair.Value.Type); } } Guid id = GuidUtility.Create(GuidUtility.TraceLabNamespace, componentInfo.ToString()); return(id.ToString()); }
private void BuildOutputDictionary(IOSpecDefinition iOSpec) { Output.Clear(); foreach (IOItemDefinition itemDefinition in iOSpec.Output.Values) { var item = new IOItem(itemDefinition, itemDefinition.Name); Output.Add(itemDefinition.Name, item); } }
public CompositeComponentMetadataDefinition(string id) : base(id) { IOSpecDefinition = new IOSpecDefinition(); ConfigurationWrapperDefinition = new ConfigWrapperDefinition(false, null); }
private CompositeComponentMetadataDefinition() { IOSpecDefinition = new IOSpecDefinition(); ConfigurationWrapperDefinition = new ConfigWrapperDefinition(false, null); }
/// <summary> /// Initializes a new s_instance of the <see cref="IOSpec"/> class. /// </summary> /// <param name="iOSpec">The IO spec definition.</param> public IOSpec(IOSpecDefinition iOSpec) : this() { BuildInputDictionary(iOSpec); BuildOutputDictionary(iOSpec); }
public CompositeComponentMetadataDefinition(string id) : base(id) { IOSpecDefinition = new IOSpecDefinition(); ConfigurationWrapperDefinition = new ConfigWrapperDefinition(false, null); }
private CompositeComponentMetadataDefinition() { IOSpecDefinition = new IOSpecDefinition(); ConfigurationWrapperDefinition = new ConfigWrapperDefinition(false, null); }
public IOSpecDefinition(IOSpecDefinition iOSpec) { Input = new Dictionary<string, IOItemDefinition>(iOSpec.Input); Output = new Dictionary<string, IOItemDefinition>(iOSpec.Output); }
public IOSpecDefinition(IOSpecDefinition iOSpec) { Input = new Dictionary <string, IOItemDefinition>(iOSpec.Input); Output = new Dictionary <string, IOItemDefinition>(iOSpec.Output); }
/// <summary> /// Reads the IO spec attributes and creates iospec definition /// </summary> /// <param name="componentType">Type of the component.</param> /// <exception cref="ComponentsLibraryException">throws components exception if there are two same inputs or outputs of the same name /// added to io spec defnition</exception> /// <returns>IOSpecDefinition if there were no errors</returns> internal static IOSpecDefinition ReadIOSpec(Type componentType) { var spec = new IOSpecDefinition(); object[] inputMapping = componentType.GetCustomAttributes(typeof(IOSpecAttribute), true); if (inputMapping.Length != 0) { foreach (IOSpecAttribute attrib in inputMapping) { if (attrib.IOType == IOSpecType.Input) { if (spec.Input.ContainsKey(attrib.Name)) { throw new ComponentsLibraryException(String.Format("There cannot be multiple input attributes of the same name '{0}'", attrib.Name)); } spec.Input.Add(attrib.Name, new IOItemDefinition(attrib.Name, attrib.DataType.FullName, attrib.Description, IOSpecType.Input)); } else if (attrib.IOType == IOSpecType.Output) { if (spec.Output.ContainsKey(attrib.Name)) { throw new ComponentsLibraryException(String.Format("There cannot be multiple output attributes of the same name '{0}'", attrib.Name)); } spec.Output.Add(attrib.Name, new IOItemDefinition(attrib.Name, attrib.DataType.FullName, attrib.Description, IOSpecType.Output)); } else { throw new ComponentsLibraryException("IOSpecType enumeration is invalid"); } } } return spec; }
/// <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> public ComponentMetadataDefinition(string id, string assembly, string classname) : base(id, assembly, classname) { IOSpecDefinition = new IOSpecDefinition(); }
/// <summary> /// Extracts types assemblies from the given IOSpecDefinition. /// </summary> /// <param name="pIOSpecDefinition">IO Spec Definition of a component.</param> private void ExtractTypesFromIOSpec(IOSpecDefinition pIOSpecDefinition) { CollectTypeAssemblies(pIOSpecDefinition.Input); CollectTypeAssemblies(pIOSpecDefinition.Output); }
/// <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> public ComponentMetadataDefinition(string id, string assembly, string classname) : base(id, assembly, classname) { IOSpecDefinition = new IOSpecDefinition(); }
/// <summary> /// Initializes a new s_instance of the <see cref="IOSpec"/> class. /// </summary> /// <param name="iOSpec">The IO spec definition.</param> public IOSpec(IOSpecDefinition iOSpec) : this() { BuildInputDictionary(iOSpec); BuildOutputDictionary(iOSpec); }
public void CreateComponentIdTestIOSpec() { string componentName = "Mock component"; IOSpecDefinition componentIOSpec = new IOSpecDefinition(); componentIOSpec.Input.Add("mockinput", new IOItemDefinition("mockinput", "mocktype", "mockdescription", TraceLabSDK.IOSpecType.Input)); componentIOSpec.Output.Add("mockoutput", new IOItemDefinition("mockoutput", "mocktype", "mockdescription", TraceLabSDK.IOSpecType.Output)); string version = "1.0"; ConfigWrapperDefinition componentConfiguration = null; string id = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec, version, componentConfiguration); //repeat with the same data - ids should be the same string id2 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec, version, componentConfiguration); Assert.AreEqual(id, id2); //copy original iospec and add input to it IOSpecDefinition componentIOSpec2 = new IOSpecDefinition(componentIOSpec); componentIOSpec2.Input.Add("mockinput2", new IOItemDefinition("mockinput2", "mock.type", "mockdescription", TraceLabSDK.IOSpecType.Input)); string id3 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec2, version, componentConfiguration); Assert.AreNotEqual(id, id3); //copy original iospec and add output to it IOSpecDefinition componentIOSpec3 = new IOSpecDefinition(componentIOSpec); componentIOSpec3.Output.Add("mockoutput2", new IOItemDefinition("mockoutput2", "mock.type", "mockdescription", TraceLabSDK.IOSpecType.Output)); string id4 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec3, version, componentConfiguration); Assert.AreNotEqual(id, id4); //finally compare with empty iospec IOSpecDefinition componentIOSpec5 = new IOSpecDefinition(); string id6 = ComponentScannerHelper_Accessor.CreateComponentId(componentName, componentIOSpec5, version, componentConfiguration); Assert.AreNotEqual(id, id6); }