Beispiel #1
0
        /// <summary>
        /// Performs a deep copy of the data in this object to another instance of the Metadata.
        /// </summary>
        /// <param name="other">The other.</param>
        protected override void CopyFrom(Metadata other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            base.CopyFrom(other);

            CompositeComponentMetadata metadata = (CompositeComponentMetadata)other;

            m_IOSpec                 = metadata.m_IOSpec.Clone();
            m_configWrapper          = metadata.m_configWrapper.Clone();
            m_experimentLocationRoot = metadata.m_experimentLocationRoot;
            m_compositeComponentMetadataDefinition = metadata.m_compositeComponentMetadataDefinition;
            m_componentMetadataDefinitionID        = metadata.m_componentMetadataDefinitionID;

            HasDeserializationError = metadata.HasDeserializationError;
            if (HasDeserializationError)
            {
                DeserializationErrorMessage = metadata.DeserializationErrorMessage;
            }

            // if composite component was not present in the library, then corresponding component graph may be null.
            // the deserialization has already set the corresponding error above, nevertheless subgraph cannot be cloned obviously
            if (HasDeserializationError == false && metadata.m_compositeComponentGraph != null)
            {
                m_compositeComponentGraph = (CompositeComponentGraph)(metadata.m_compositeComponentGraph.Clone());
            }

            m_tempConfigWrapper = metadata.m_tempConfigWrapper;
            m_tempIoSpec        = metadata.m_tempIoSpec;
            m_tempLabel         = metadata.m_tempLabel;
        }
 /// <summary>
 /// Initializes a new s_instance of the <see cref="CompositeComponentMetadata"/> class.
 /// </summary>
 /// <param name="compositeComponentMetadataDefinition">The composite component metadata definition.</param>
 internal CompositeComponentMetadata(CompositeComponentMetadataDefinition compositeComponentMetadataDefinition, string experimentLocationRoot)
     : this()
 {
     m_experimentLocationRoot = experimentLocationRoot;
     ComponentMetadataDefinition = compositeComponentMetadataDefinition;
     InitDefaultComponentMetadata(true);
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new s_instance of the <see cref="CompositeComponentMetadata"/> class.
 /// </summary>
 /// <param name="compositeComponentMetadataDefinition">The composite component metadata definition.</param>
 internal CompositeComponentMetadata(CompositeComponentMetadataDefinition compositeComponentMetadataDefinition, string experimentLocationRoot)
     : this()
 {
     m_experimentLocationRoot    = experimentLocationRoot;
     ComponentMetadataDefinition = compositeComponentMetadataDefinition;
     InitDefaultComponentMetadata(true);
 }
        /// <summary>
        /// Generates the final composite component definition.
        /// </summary>
        /// <returns></returns>
        internal TraceLab.Core.Components.CompositeComponentMetadataDefinition GenerateCompositeComponentDefinition()
        {
            var componentId = Guid.NewGuid().ToString();

            //first create CompositeComponentMetadefinition based on ExportSettings
            TraceLab.Core.Components.CompositeComponentMetadataDefinition componentDefinition =
                new TraceLab.Core.Components.CompositeComponentMetadataDefinition(
                    componentId,
                    CompositeComponentGraph,
                    CompositeComponentLocationFilePath,
                    Name,
                    Name,
                    Version,
                    Description,
                    Author,
                    new Components.ComponentTags(componentId),
                    new List <DocumentationLink>());

            foreach (string itemName in InputSettings.Keys)
            {
                ItemSetting item = InputSettings[itemName];
                if (item.Include == true)
                {
                    if (componentDefinition.IOSpecDefinition.Input.ContainsKey(itemName) == false)
                    {
                        componentDefinition.IOSpecDefinition.Input.Add(itemName, new TraceLab.Core.Components.IOItemDefinition(itemName, item.Type, item.Description, TraceLabSDK.IOSpecType.Input));
                    }
                }
            }

            foreach (string itemName in OutputSettings.Keys)
            {
                ItemSetting item = OutputSettings[itemName];
                if (item.Include == true)
                {
                    if (componentDefinition.IOSpecDefinition.Output.ContainsKey(itemName) == false)
                    {
                        componentDefinition.IOSpecDefinition.Output.Add(itemName, new TraceLab.Core.Components.IOItemDefinition(itemName, item.Type, item.Description, TraceLabSDK.IOSpecType.Output));
                    }
                }
            }

            foreach (ConfigItemSetting item in ConfigSettings.Values)
            {
                //note here we add all config values, but only some of them are visible at the top level in the property grid
                if (componentDefinition.ConfigurationWrapperDefinition.Properties.ContainsKey(item.Alias) == false)
                {
                    componentDefinition.ConfigurationWrapperDefinition.AddProperty(item.PropertyObject);
                }
            }
            return(componentDefinition);
        }
        /// <summary>
        /// Defines the component.
        /// StreamWriter throws several exceptions. For each of those there should be proper test
        /// </summary>
        public void DefineComponent()
        {
            TraceLab.Core.Components.CompositeComponentMetadataDefinition componentDefinition = GenerateCompositeComponentDefinition();

            var serializer = TraceLab.Core.Serialization.XmlSerializerFactory.GetSerializer(typeof(TraceLab.Core.Components.CompositeComponentMetadataDefinition), null);

            using (TextWriter writer = new StreamWriter(CompositeComponentLocationFilePath))
            {
                serializer.Serialize(writer, componentDefinition);
                writer.Close();
            }

            if (addToComponentLibrary != null)
            {
                addToComponentLibrary(componentDefinition);
            }
        }
        /// <summary>
        /// Generates the final composite component definition.
        /// </summary>
        /// <returns></returns>
        internal TraceLab.Core.Components.CompositeComponentMetadataDefinition GenerateCompositeComponentDefinition()
        {
            var componentId = Guid.NewGuid().ToString();
            //first create CompositeComponentMetadefinition based on ExportSettings
            TraceLab.Core.Components.CompositeComponentMetadataDefinition componentDefinition =
                new TraceLab.Core.Components.CompositeComponentMetadataDefinition(
                    componentId,
                    CompositeComponentGraph,
                    CompositeComponentLocationFilePath,
                    Name,
                    Name,
                    Version,
                    Description,
                    Author,
                    new Components.ComponentTags(componentId),
                    new List<DocumentationLink>());

            foreach (string itemName in InputSettings.Keys)
            {
                ItemSetting item = InputSettings[itemName];
                if (item.Include == true)
                {
                    if (componentDefinition.IOSpecDefinition.Input.ContainsKey(itemName) == false)
                    {
                        componentDefinition.IOSpecDefinition.Input.Add(itemName, new TraceLab.Core.Components.IOItemDefinition(itemName, item.Type, item.Description, TraceLabSDK.IOSpecType.Input));
                    }
                }
            }

            foreach (string itemName in OutputSettings.Keys)
            {
                ItemSetting item = OutputSettings[itemName];
                if (item.Include == true)
                {
                    if (componentDefinition.IOSpecDefinition.Output.ContainsKey(itemName) == false)
                    {
                        componentDefinition.IOSpecDefinition.Output.Add(itemName, new TraceLab.Core.Components.IOItemDefinition(itemName, item.Type, item.Description, TraceLabSDK.IOSpecType.Output));
                    }
                }
            }

            foreach (ConfigItemSetting item in ConfigSettings.Values)
            {
                //note here we add all config values, but only some of them are visible at the top level in the property grid
                if (componentDefinition.ConfigurationWrapperDefinition.Properties.ContainsKey(item.Alias) == false)
                {
                    componentDefinition.ConfigurationWrapperDefinition.AddProperty(item.PropertyObject);
                }
            }
            return componentDefinition;
        }
        /// <summary>
        /// Performs a deep copy of the data in this object to another instance of the Metadata.
        /// </summary>
        /// <param name="other">The other.</param>
        protected override void CopyFrom(Metadata other)
        {
            if (other == null)
                throw new ArgumentNullException("other");
            
            base.CopyFrom(other);

            CompositeComponentMetadata metadata = (CompositeComponentMetadata)other;
            m_IOSpec = metadata.m_IOSpec.Clone();
            m_configWrapper = metadata.m_configWrapper.Clone();
            m_experimentLocationRoot = metadata.m_experimentLocationRoot;
            m_compositeComponentMetadataDefinition = metadata.m_compositeComponentMetadataDefinition;
            m_componentMetadataDefinitionID = metadata.m_componentMetadataDefinitionID;

            HasDeserializationError = metadata.HasDeserializationError;
            if (HasDeserializationError)
            {
                DeserializationErrorMessage = metadata.DeserializationErrorMessage;
            } 

            // if composite component was not present in the library, then corresponding component graph may be null.
            // the deserialization has already set the corresponding error above, nevertheless subgraph cannot be cloned obviously
            if (HasDeserializationError == false && metadata.m_compositeComponentGraph != null)
            {
                m_compositeComponentGraph = (CompositeComponentGraph)(metadata.m_compositeComponentGraph.Clone());
            }

            m_tempConfigWrapper = metadata.m_tempConfigWrapper;
            m_tempIoSpec = metadata.m_tempIoSpec;
            m_tempLabel = metadata.m_tempLabel;
        }
        public void AddReplaceCompositeComponentMetadataDefinition(CompositeComponentMetadataDefinition metadataDefinition) 
        {
            var library = (ComponentsLibrary)m_componentsLibraryViewModel;

            //if there is old composite component definition that had the same source, remove it from library
            CompositeComponentMetadataDefinition oldMetadataDefinition;
            if (library.TryFindCompositeComponentMetadataDefinition(metadataDefinition.Assembly, out oldMetadataDefinition))
            {
                RemoveFromCLVHierarchy(oldMetadataDefinition, m_nodeCollection);
                library.Remove(oldMetadataDefinition);
            }

            library.Add(metadataDefinition);
            AddNodeTag(metadataDefinition);
        }
 public CompositeComponentFileDescriptor(string filePath, CompositeComponentMetadataDefinition metadata)
     : base(filePath)
 {
     this.m_metadataDefinition = metadata;
 }
 public CompositeComponentFileDescriptor(string filePath, CompositeComponentMetadataDefinition metadata)
     : base(filePath)
 {
     this.m_metadataDefinition = metadata;
 }