Esempio n. 1
0
        public void ParseAndWrite(PARSE_TYPE type, string inputText)
        {
            // parse through framework
            SyntaxTree tree = new N.CSharpParser().Parse(inputText);

            // dispatch to visitor
            var defaultVisitor = new NRefactoryVisitor();
            tree.AcceptVisitor(defaultVisitor);

            IEnumerable<CLRType> CLRTypesDetected = defaultVisitor.CLRTypes;
            switch (type)
            {
                case PARSE_TYPE.FIELDS:
                    CLRTypesDetected.ToList().ForEach(clrType => clrType.WriteFieldsUML(m_richSb));
                    break;

                case PARSE_TYPE.PROPERTIES:
                    CLRTypesDetected.ToList().ForEach(clrType => clrType.WritePropertiesUML(m_richSb));
                    break;

                case PARSE_TYPE.METHODS:
                    CLRTypesDetected.ToList().ForEach(clrType => clrType.WriteMethodsUML(m_richSb));
                    break;

                case PARSE_TYPE.ALL:
                    CLRTypesDetected.ToList().ForEach(clrType => clrType.Design(m_richSb));
                    break;

                default:
                    throw new NotSupportedException();

            }
        }
        public string Parse(PARSE_TYPE type, string inputText)
        {
            // parse through framework
            SyntaxTree tree = new N.CSharpParser().Parse(inputText);

            // dispatch to visitor
            var defaultVisitor = new NRefactoryVisitor();
            tree.AcceptVisitor(defaultVisitor);

            IEnumerable<CLRType> inputTextTypes = defaultVisitor.CLRTypes;
            switch (type)
            {
                case PARSE_TYPE.FIELDS:
                    return inputTextTypes.Aggregate(new StringBuilder(), (sb, clr) => sb.AppendLine(clr.GetFieldsUML())).ToString();

                case PARSE_TYPE.PROPERTIES:
                    return inputTextTypes.Aggregate(new StringBuilder(), (sb, clr) => sb.AppendLine(clr.GetPropertiesUML())).ToString();

                case PARSE_TYPE.METHODS:
                    return inputTextTypes.Aggregate(new StringBuilder(), (sb, clr) => sb.AppendLine(clr.GetMethodsUML())).ToString();

                case PARSE_TYPE.ALL:
                    return inputTextTypes.Aggregate(new StringBuilder(), (sb, clr) => sb.AppendLine(clr.Design())).ToString();

                default:
                    throw new NotSupportedException();

            }
        }