/// <summary>
        ///   Writes the attribute specification to a stream.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the attribute specification 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="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;
            }

            Dictionary <string, string[]> lookup = new Dictionary <string, string[]>(2);

            lookup.Add("Summary", new string[] { Summary });
            if (!string.IsNullOrWhiteSpace(Remarks))
            {
                lookup.Add("Remarks", new string[] { Remarks });
            }

            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteGeneralDocumentationElements(wr, lookup, indentOffset);
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteLine(wr, string.Format("attribute {0} of {1} : {2} is {3};", Declaration.Name, Item.Name, GetItemString(), Value), indentOffset);
        }
Пример #2
0
        /// <summary>
        ///   Writes the basic file header composed of the summary and remarks section.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the header 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="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        public void WriteBasicHeader(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

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

            Dictionary <string, string[]> lookup = new Dictionary <string, string[]>(2);

            lookup.Add("Summary", new string[] { Summary });
            if (!string.IsNullOrWhiteSpace(Remarks))
            {
                lookup.Add("Remarks", new string[] { Remarks });
            }

            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteGeneralDocumentationElements(wr, lookup, indentOffset);
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
        }
Пример #3
0
        /// <summary>
        ///   Writes the entity 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">The number of ports and generics is zero.</exception>
        /// <exception cref="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        public override void Write(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

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

            if (Generics.Count == 0 && Ports.Count == 0)
            {
                throw new InvalidOperationException(string.Format("An attempt was made to write an entity ({0}), but the entity does not have any ports or generics.", Name));
            }

            // Generate the documentation lookup table.
            Dictionary <string, string[]> lookup = new Dictionary <string, string[]>();

            lookup.Add("Summary", new string[] { Summary });

            if (Generics.Count > 0)
            {
                List <string> subItems = new List <string>(Generics.Count);
                foreach (GenericInfo info in Generics)
                {
                    subItems.Add(info.GetDocumentationString());
                }
                lookup.Add("Generics", subItems.ToArray());
            }

            if (Ports.Count > 0)
            {
                List <string> subItems = new List <string>(Ports.Count);
                foreach (PortInfo info in Ports)
                {
                    subItems.Add(info.GetDocumentationString());
                }
                lookup.Add("Ports", subItems.ToArray());
            }

            if (!string.IsNullOrWhiteSpace(Remarks))
            {
                lookup.Add("Remarks", new string[] { Remarks });
            }

            // Write the header.
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteGeneralDocumentationElements(wr, lookup, indentOffset);
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteLine(wr, string.Format("entity {0} is", Name), indentOffset);

            if (Generics.Count > 0)
            {
                SimplifiedGenericInfo.WriteGenericDeclaration(wr, Generics.ToArray(), indentOffset);
            }

            if (Ports.Count > 0)
            {
                SimplifiedPortInfo.WritePortDeclaration(wr, Ports.ToArray(), indentOffset);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("end");
            if (DefaultValues.AddOptionalTypeNames)
            {
                sb.Append(" entity");
            }
            if (DefaultValues.AddOptionalNames)
            {
                sb.AppendFormat(" {0}", Name);
            }
            sb.Append(";");
            DocumentationHelper.WriteLine(wr, sb.ToString(), indentOffset);
        }
Пример #4
0
        /// <summary>
        ///   Writes the procedure to a stream.
        /// </summary>
        /// <param name="wr"><see cref="StreamWriter"/> object to write the procedure 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">No code lines were specified or no parameters were specified.</exception>
        /// <exception cref="IOException">An error occurred while writing to the <see cref="StreamWriter"/> object.</exception>
        public override void Write(StreamWriter wr, int indentOffset)
        {
            if (wr == null)
            {
                throw new ArgumentNullException("wr");
            }

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

            if (CodeLines.Count == 0)
            {
                throw new InvalidOperationException(string.Format("An attempt was made to write a procedure ({0}), but it doesn't have any code associated with it", Name));
            }
            if (Parameters.Count == 0)
            {
                throw new InvalidOperationException(string.Format("An attempt was made to write a procedure ({0}), but it doesn't have any parameters", Name));
            }

            // Generate the documentation lookup table.
            Dictionary <string, string[]> lookup = new Dictionary <string, string[]>();

            lookup.Add("Summary", new string[] { Summary });

            if (Parameters.Count > 0)
            {
                List <string> subItems = new List <string>(Parameters.Count);
                foreach (ProcedureParameterInfo info in Parameters)
                {
                    subItems.Add(info.GetDocumentationString());
                }
                lookup.Add("Parameters", subItems.ToArray());
            }

            if (!string.IsNullOrWhiteSpace(Remarks))
            {
                lookup.Add("Remarks", new string[] { Remarks });
            }

            // Write the header.
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteGeneralDocumentationElements(wr, lookup, indentOffset);
            DocumentationHelper.WriteFlowerLine(wr, indentOffset);
            DocumentationHelper.WriteLine(wr, GetSignature(), indentOffset);

            // Write the variable declarations out.
            BaseTypeInfo.WriteBaseTypeInfos(null, wr, Variables.ToArray(), indentOffset + 1, Name, "procedure");

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

            // Write the code lines.
            foreach (string line in CodeLines)
            {
                DocumentationHelper.WriteLine(wr, line, indentOffset + 1);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("end");
            if (DefaultValues.AddOptionalTypeNames)
            {
                sb.Append(" procedure");
            }
            if (DefaultValues.AddOptionalNames)
            {
                sb.AppendFormat(" {0}", Name);
            }
            sb.Append(";");
            DocumentationHelper.WriteLine(wr, sb.ToString(), indentOffset);
        }