Beispiel #1
0
        public IRichStringbuilder Design(IRichStringbuilder richSb)
        {
            // Header
            DesignHeader(richSb);

            // REFERENCES
            if (ReferencedTypes.Any())
            {
                richSb.WriteLine();
                DrawLine(richSb, 50, true, '-');
                WriteReferencesUML(richSb);
                DrawLine(richSb, 50, true, '-');
            }

            // PROPERTIES
            if (Properties.Any())
            {
                richSb.WriteLine();
                richSb.WriteRegular("Properties ").WriteLine();
                WritePropertiesUML(richSb);
            }

            // METHODS
            if (Methods.Any())
            {
                richSb.WriteLine();
                richSb.WriteRegular("Methods ").WriteLine();
                WriteMethodsUML(richSb);
            }

            return richSb;
        }
Beispiel #2
0
        protected static void DrawLine(IRichStringbuilder builder, int size, bool useIntercalatedSpace, char c, bool appendLineAtTheEnd = true, bool writingHeader = false)
        {
            Action<bool, string> internalFunc = (header, data) =>
            {
                if (header) { builder.WriteBold(data); }
                else { builder.WriteRegular(data); }
            };

            if (useIntercalatedSpace)
            {
                for (int i = 0;
                     i < size;
                     internalFunc(writingHeader, (i % 2 == 0 ? "" + c : " ")), i++) ;
            }

            else
            {
                for (int i = 0;
                     i < size;
                     internalFunc(writingHeader, ("" + c)), i++) ;
            }

            if (appendLineAtTheEnd)
            {
                builder.WriteLine();
            }
        }
        public void DesignHeader(IRichStringbuilder richSb)
        {
            int LINE_CHARS_NUM = Name.Length + 5;
            DrawLine(richSb, LINE_CHARS_NUM, true, '_', true, true);
            richSb.WriteRegular(": ");
            Visibility.Design(richSb);
            richSb.WriteRegular(Name);

            int charsWritten = DesignHeaderConcrete(richSb);

            if (BaseTypes.Any())
            {
                richSb.WriteRegular(" : ");
                charsWritten += (int) Math.Round((double)WriteBaseTypesUML(richSb) * 1.7d);
            }

            richSb.WriteLine();
            DrawLine(richSb, LINE_CHARS_NUM + charsWritten, true, '¯', true, true);
        }
Beispiel #4
0
        private IRichStringbuilder DesignHeader(IRichStringbuilder richSb)
        {
            int LINE_CHARS_NUM = Name.Length + 5;
            DrawLine(richSb, LINE_CHARS_NUM, true, '_', true, true);
            richSb.WriteRegular(": ");
            Visibility.Design(richSb);
            richSb.WriteRegular(Name);

            richSb.WriteRegular(" ");
            richSb.WriteItalic(ENUM_WORD);
            LINE_CHARS_NUM += ENUM_WORD.Length;

            richSb.WriteLine();
            DrawLine(richSb, LINE_CHARS_NUM, true, '¯', true, true);
            return richSb;
        }
Beispiel #5
0
        public IRichStringbuilder Design(IRichStringbuilder richSb)
        {
            string dummyTextPreparation = Name;
            Func<string> annotationString = () =>
            {
                string s = string.Empty;
                switch (Type)
                {
                    case CLRAvailableTypeMode.@class:
                        if (Abstract) s = "« abstract »";
                        break;
                    case CLRAvailableTypeMode.@enum:
                        s = " « enum »";
                        break;

                    case CLRAvailableTypeMode.@interface:
                        s = " « interface »";
                        break;

                    case CLRAvailableTypeMode.@struct:
                        s = " « struct »";
                        break;

                    default: throw new NotSupportedException();
                }

                return s;
            };

            if (!string.IsNullOrEmpty(BaseName)) { dummyTextPreparation += " extends " + BaseName; }
            string annotationText = annotationString();
            dummyTextPreparation += annotationText;         // append

            // calc size
            int numCharsOthersSeparators = (int)Math.Round(dummyTextPreparation.Length * 0.8);
            int numCharsClass = (int)Math.Round((dummyTextPreparation.Length * 1.3));        // fixed value because of the caracter _

            DrawLine(richSb, numCharsClass, true, '_', true, true);
            richSb.WriteRegular(": ");
            Visibility.Design(richSb);
            richSb.WriteRegular(" " + Name);

            if (!string.IsNullOrEmpty(annotationText)) { richSb.WriteItalic(annotationText); }
            if (!string.IsNullOrEmpty(BaseName)) { richSb.WriteRegular(" extends ").WriteBold(BaseName); }

            richSb.WriteLine();
            DrawLine(richSb, numCharsClass, true, '¯', true, true);

            // REFERENCES
            if (ReferencedTypes.Any())
            {
                richSb.WriteLine();
                DrawLine(richSb, numCharsOthersSeparators, true, '-');
                WriteReferencesUML(richSb);
                DrawLine(richSb, numCharsOthersSeparators, true, '-');
            }

            // CONSTANTS
            if (ConstantFields.Any())
            {
                richSb.WriteLine();
                richSb.WriteRegular("CONSTANTS ").WriteLine();
                WriteConstantsUML(richSb);
            }

            // FIELDS
            if (Fields.Any())
            {
                richSb.WriteLine();
                richSb.WriteRegular("Fields ").WriteLine();
                WriteFieldsUML(richSb);
            }

            // PROPERTIES
            if (Properties.Any())
            {
                richSb.WriteLine();
                richSb.WriteRegular("Properties ").WriteLine();
                WritePropertiesUML(richSb);
            }

            // METHODS

            if (Methods.Any())
            {
                richSb.WriteLine();
                richSb.WriteRegular("Methods ").WriteLine();
                WriteMethodsUML(richSb);
            }

            return richSb;
        }