/// <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>
 /// 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;
     }
 }
Beispiel #5
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;
     }
 }
Beispiel #6
0
        /// <summary>
        /// This method creates ConfigWrapperDefinition based on the given configType. In case in config files written in C# it will use Properties as Config parameters.
        /// In case of Java it will scan for pairs of getters and setters, and if it will find one it will create a property for it. For example void setTest(string value) and string getTest()
        /// will generate property 'string Test'
        /// </summary>
        /// <param name="configType"></param>
        /// <returns></returns>
        internal static ConfigWrapperDefinition CreateConfigWrapperDefinition(Type configType)
        {
            ConfigWrapperDefinition configWrapperDefinition = null;

            if (configType != null)
            {
                bool isJava = CheckIfJavaType(configType);

                configWrapperDefinition = new ConfigWrapperDefinition(isJava, configType.FullName);

                if (isJava == false)
                {
                    System.ComponentModel.PropertyDescriptorCollection properties = System.ComponentModel.TypeDescriptor.GetProperties(configType);
                    configWrapperDefinition.AddProperties(properties);
                }
                else
                {
                    //check for java if there are any java getters
                    String getterPrefix         = "get";
                    String setterPrefix         = "set";
                    String getterPropertyPrefix = "get_"; // .net style getter generated for properties

                    MethodInfo[] methods = configType.GetMethods(BindingFlags.Public | BindingFlags.Instance);

                    foreach (MethodInfo method in methods)
                    {
                        if (method.Name.StartsWith(getterPrefix, StringComparison.InvariantCulture) == true && method.Name.StartsWith(getterPropertyPrefix, StringComparison.InvariantCulture) == false)
                        {
                            String propertyName = method.Name.Substring(getterPrefix.Length);
                            Type   propertyType = method.ReturnParameter.ParameterType;
                            //check if there is any corresponding set method for this property
                            if (methods.Any(item => item.Name.Equals(setterPrefix + propertyName, StringComparison.CurrentCulture)))
                            {
                                //check if setter has one input of the same type as the getter return type
                                MethodInfo setter = configType.GetMethod(setterPrefix + propertyName, BindingFlags.Public | BindingFlags.Instance, null, new Type[] { propertyType }, null);
                                if (setter != null)
                                {
                                    //TODO: Description for hava config values
                                    string propertyDescription = propertyName;
                                    //finally add the property
                                    configWrapperDefinition.AddProperty(propertyName, method.ReturnParameter.ParameterType.FullName, method.ReturnParameter.ParameterType.AssemblyQualifiedName, propertyName, propertyDescription);
                                }
                            }
                        }
                    }
                }
            }
            return(configWrapperDefinition);
        }
Beispiel #7
0
        public override bool Equals(object obj)
        {
            ConfigWrapperDefinition other = obj as ConfigWrapperDefinition;

            if (other == null)
            {
                return(false);
            }

            bool isEqual = true;

            isEqual &= object.Equals(IsJava, other.IsJava);
            isEqual &= TraceLab.Core.Utilities.CollectionsHelper.DictionaryContentEquals <string, ConfigPropertyObject>(Properties, other.Properties);

            return(isEqual);
        }
 public CompositeComponentMetadataDefinition(string id)
     : base(id)
 {
     IOSpecDefinition = new IOSpecDefinition();
     ConfigurationWrapperDefinition = new ConfigWrapperDefinition(false, null);
 }
 private CompositeComponentMetadataDefinition()
 {
     IOSpecDefinition = new IOSpecDefinition();
     ConfigurationWrapperDefinition = new ConfigWrapperDefinition(false, null);
 }
Beispiel #10
0
 protected ConfigWrapper(SerializationInfo info, StreamingContext context)
 {
     m_configWrapperDefinition = (ConfigWrapperDefinition)info.GetValue("m_configWrapperDefinition", typeof(ConfigWrapperDefinition));
     m_isJava       = (bool)info.GetValue("m_isJava", typeof(bool));
     m_configValues = (ObservableDictionary <string, ConfigPropertyObject>)info.GetValue("m_configValues", typeof(ObservableDictionary <string, ConfigPropertyObject>));
 }
 private CompositeComponentMetadataDefinition()
 {
     IOSpecDefinition = new IOSpecDefinition();
     ConfigurationWrapperDefinition = new ConfigWrapperDefinition(false, null);
 }
        /// <summary>
        /// This method creates ConfigWrapperDefinition based on the given configType. In case in config files written in C# it will use Properties as Config parameters.
        /// In case of Java it will scan for pairs of getters and setters, and if it will find one it will create a property for it. For example void setTest(string value) and string getTest()
        /// will generate property 'string Test'
        /// </summary>
        /// <param name="configType"></param>
        /// <returns></returns>
        internal static ConfigWrapperDefinition CreateConfigWrapperDefinition(Type configType)
        {
            ConfigWrapperDefinition configWrapperDefinition = null;

            if (configType != null)
            {
                bool isJava = CheckIfJavaType(configType);

                configWrapperDefinition = new ConfigWrapperDefinition(isJava, configType.FullName);

                if (isJava == false)
                {
                    System.ComponentModel.PropertyDescriptorCollection properties = System.ComponentModel.TypeDescriptor.GetProperties(configType);
                    configWrapperDefinition.AddProperties(properties);
                }
                else
                {
                    //check for java if there are any java getters
                    String getterPrefix = "get";
                    String setterPrefix = "set";
                    String getterPropertyPrefix = "get_"; // .net style getter generated for properties

                    MethodInfo[] methods = configType.GetMethods(BindingFlags.Public | BindingFlags.Instance);

                    foreach (MethodInfo method in methods)
                    {
                        if (method.Name.StartsWith(getterPrefix, StringComparison.InvariantCulture) == true && method.Name.StartsWith(getterPropertyPrefix, StringComparison.InvariantCulture) == false)
                        {
                            String propertyName = method.Name.Substring(getterPrefix.Length);
                            Type propertyType = method.ReturnParameter.ParameterType;
                            //check if there is any corresponding set method for this property
                            if (methods.Any(item => item.Name.Equals(setterPrefix + propertyName, StringComparison.CurrentCulture)))
                            {
                                //check if setter has one input of the same type as the getter return type
                                MethodInfo setter = configType.GetMethod(setterPrefix + propertyName, BindingFlags.Public | BindingFlags.Instance, null, new Type[] { propertyType }, null);
                                if (setter != null)
                                {
                                    //TODO: Description for hava config values
                                    string propertyDescription = propertyName;
                                    //finally add the property
                                    configWrapperDefinition.AddProperty(propertyName, method.ReturnParameter.ParameterType.FullName, method.ReturnParameter.ParameterType.AssemblyQualifiedName, propertyName, propertyDescription);
                                }
                            }
                        }
                    }
                }
            }
            return configWrapperDefinition;
        }
Beispiel #13
0
        /// <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());
        }
 internal ConfigWrapper(ConfigWrapperDefinition configDefinition)
 {
     m_configWrapperDefinition = configDefinition;
     InitDefaultConfigWrapper();
 }
 public CompositeComponentMetadataDefinition(string id)
     : base(id)
 {
     IOSpecDefinition = new IOSpecDefinition();
     ConfigurationWrapperDefinition = new ConfigWrapperDefinition(false, null);
 }
 protected ConfigWrapper(SerializationInfo info, StreamingContext context)
 {
     m_configWrapperDefinition = (ConfigWrapperDefinition)info.GetValue("m_configWrapperDefinition", typeof(ConfigWrapperDefinition));
     m_isJava = (bool)info.GetValue("m_isJava", typeof(bool));
     m_configValues = (ObservableDictionary<string, ConfigPropertyObject>)info.GetValue("m_configValues", typeof(ObservableDictionary<string, ConfigPropertyObject>));
 }
Beispiel #17
0
 internal ConfigWrapper(ConfigWrapperDefinition configDefinition)
 {
     m_configWrapperDefinition = configDefinition;
     InitDefaultConfigWrapper();
 }