Пример #1
0
        /// <summary>
        ///   Validates that all the child names are unique.
        /// </summary>
        /// <exception cref="InvalidOperationException">Two child objects were found with the same name.</exception>
        private void ValidateChildNames()
        {
            List <BaseTypeInfo> childList = new List <BaseTypeInfo>();

            childList.AddRange(DeclaredTypes);
            childList.AddRange(Functions);
            childList.AddRange(Procedures);
            childList.AddRange(SubModule.GetUniqueComponents(SubModules, true));
            childList.AddRange(Signals);
            childList.AddRange(Aliases);
            childList.AddRange(AttributeDeclarationInfo.GetUniqueAttributeDeclarations(Attributes));
            childList.AddRange(Processes);
            childList.AddRange(Generates);
            childList.AddRange(SubModules);

            BaseTypeInfo.ValidateNoDuplicates(childList.ToArray(), Entity.Name, "module");
        }
Пример #2
0
        /// <summary>
        ///   Generates the module sub-information.
        /// </summary>
        /// <param name="info"><see cref="ModuleInfo"/> object to generate the sub-information on.</param>
        /// <returns>Lookup table of the sub-information.</returns>
        private Dictionary <string, List <string> > GenerateModuleSubInfo(ModuleInfo info)
        {
            Dictionary <string, List <string> > lookup = new Dictionary <string, List <string> >();

            // Add Functions.
            if (info.Functions.Count > 0)
            {
                info.Functions.Sort();
                lookup.Add("Functions:", GenerateNamesFromBaseTypeInfo(info.Functions.ToArray()));
            }

            // Add Declarations.
            if (info.DeclaredTypes.Count > 0)
            {
                info.DeclaredTypes.Sort();
                lookup.Add("Constants & Types:", GenerateNamesFromBaseTypeInfo(info.DeclaredTypes.ToArray()));
            }

            // Add Procedures.
            if (info.Procedures.Count > 0)
            {
                info.Procedures.Sort();
                lookup.Add("Procedures:", GenerateNamesFromBaseTypeInfo(info.Procedures.ToArray()));
            }

            if (info.SubModules.Count > 0)
            {
                info.SubModules.Sort();
            }

            // Add Components.
            ComponentInfo[] components = SubModule.GetUniqueComponents(info.SubModules, true);
            if (components.Length > 0)
            {
                lookup.Add("Components:", GenerateNamesFromBaseTypeInfo(components));
            }

            // Add Signals.
            if (info.Signals.Count > 0)
            {
                info.Signals.Sort();
                lookup.Add("Signals:", GenerateNamesFromBaseTypeInfo(info.Signals.ToArray()));
            }

            // Add Aliases.
            if (info.Aliases.Count > 0)
            {
                info.Aliases.Sort();
                lookup.Add("Aliases:", GenerateNamesFromBaseTypeInfo(info.Aliases.ToArray()));
            }

            if (info.Attributes.Count > 0)
            {
                info.Attributes.Sort();
            }

            // Add Attributes.
            AttributeDeclarationInfo[] declarations = AttributeDeclarationInfo.GetUniqueAttributeDeclarations(info.Attributes);
            if (declarations.Length > 0)
            {
                lookup.Add("Attributes:", GenerateNamesFromBaseTypeInfo(declarations));
            }

            // Add Processes.
            if (info.Processes.Count > 0)
            {
                info.Processes.Sort();
                lookup.Add("Processes:", GenerateNamesFromBaseTypeInfo(info.Processes.ToArray()));
            }

            // Add Generates.
            if (info.Generates.Count > 0)
            {
                info.Generates.Sort();
                lookup.Add("Generates:", GenerateNamesFromBaseTypeInfo(info.Generates.ToArray()));
            }

            // Add Sub-Modules.
            if (info.SubModules.Count > 0)
            {
                lookup.Add("Sub-Modules:", GenerateNamesFromBaseTypeInfo(info.SubModules.ToArray()));
            }

            return(lookup);
        }