Пример #1
0
        /// <summary>
        ///   Writes the module to a stream.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the entity to.</param>
        /// <param name="indentOffset">Number of indents to add before any documentation begins.</param>
        /// <exception cref="ArgumentNullException"><paramref name="wr"/> is a null reference.</exception>
        /// <exception cref="InvalidOperationException">Unable to write the object out in its current state.</exception>
        /// <exception cref="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        public void Write(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

            if (indentOffset < 0)
            {
                indentOffset = 0;
            }

            ValidateChildNames();

            // Write the entity.
            Entity.Write(wr, indentOffset);

            DocumentationHelper.WriteLine(wr);
            DocumentationHelper.WriteLine(wr, string.Format("architecture {0} of {1} is", Enum.GetName(typeof(ArchitecturalType), Type), Entity.Name), indentOffset);
            DocumentationHelper.WriteLine(wr);

            // Functions
            BaseTypeInfo.WriteBaseTypeInfos("Functions", wr, Functions.ToArray(), indentOffset, Entity.Name, "module");
            if (Functions.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Types and Constants
            DeclarationInfo.WriteDeclarations(wr, DeclaredTypes.ToArray(), indentOffset, Entity.Name, "module");
            if (DeclaredTypes.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Procedures
            BaseTypeInfo.WriteBaseTypeInfos("Procedures", wr, Procedures.ToArray(), indentOffset, Entity.Name, "module");
            if (Procedures.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Components
            ComponentInfo[] components = SubModule.GetUniqueComponents(SubModule.GetAllSubModules(this), true);
            BaseTypeInfo.WriteBaseTypeInfos("Components", wr, components, indentOffset, Entity.Name, "module");
            if (components.Length > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Signals
            BaseTypeInfo.WriteBaseTypeInfos("Signals", wr, Signals.ToArray(), indentOffset, Entity.Name, "module");
            if (Signals.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Aliases
            BaseTypeInfo.WriteBaseTypeInfos("Aliases", wr, Aliases.ToArray(), indentOffset, Entity.Name, "module");
            if (Aliases.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Attributes
            AttributeSpecificationInfo.WriteAttributes(wr, Attributes.ToArray(), indentOffset, Entity.Name, "module");
            if (Attributes.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            DocumentationHelper.WriteLine(wr, "begin", indentOffset);
            DocumentationHelper.WriteLine(wr);

            // Concurrent Statements
            foreach (string line in ConcurrentStatements)
            {
                DocumentationHelper.WriteLine(wr, line, indentOffset);
            }
            if (ConcurrentStatements.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Processes
            BaseTypeInfo.WriteBaseTypeInfos("Processes", wr, Processes.ToArray(), indentOffset, Entity.Name, "module");
            if (Processes.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            // Generates
            BaseTypeInfo.WriteBaseTypeInfos("Generates", wr, Generates.ToArray(), indentOffset, Entity.Name, "module");
            if (Generates.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            BaseTypeInfo.WriteBaseTypeInfos("Sub-Modules", wr, SubModules.ToArray(), indentOffset, Entity.Name, "module");
            if (SubModules.Count > 0)
            {
                DocumentationHelper.WriteLine(wr);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("end");
            if (DefaultValues.AddOptionalTypeNames)
            {
                sb.Append(" architecture");
            }
            if (DefaultValues.AddOptionalNames)
            {
                sb.AppendFormat(" {0}", Enum.GetName(typeof(ArchitecturalType), Type));
            }
            sb.Append(";");
            DocumentationHelper.Write(wr, sb.ToString(), indentOffset);
        }