示例#1
0
        public CompileUnitConstructor(ASTModel astModel, MetadataRetriever metadataRetriever)
        {
            CodeDomGenerationVisitor visitor    = new CodeDomGenerationVisitor(metadataRetriever);
            CodeTypeDeclaration      modelClass = visitor.VisitAll_(astModel);

            CodeNamespace theNamespace = new CodeNamespace();

            theNamespace.Name = CompileUnitConstructor.TheNamespaceName;

            theNamespace.Types.Add(modelClass);
            theNamespace.Types.Add(RunnableClassGenerator.ConstructRunnableClass(modelClass.Name));

            this.CompileUnit = new CodeCompileUnit();
            this.CompileUnit.Namespaces.Add(theNamespace);
        }
        public CodeDomGenerationVisitor(MetadataRetriever metadataRetriever)
        {
            this.metadataRetriever = metadataRetriever;

            this.theNamespace      = new CodeNamespace();
            this.theNamespace.Name = CodeDomGenerationVisitor.TheNamespaceName;

            this.theClass            = new CodeTypeDeclaration();
            this.theClass.Attributes = MemberAttributes.Public;
            this.theClass.Name       = CodeDomGenerationVisitor.TheClassName;
            this.theClass.BaseTypes.Add(typeof(AbstractModel));
            this.theNamespace.Types.Add(this.theClass);

            //
            this.theNamespace.Types.Add(RunnableClassGenerator.ConstructRunnableClass(TheClassName));
            //

            this.theConstructor            = new CodeConstructor();
            this.theConstructor.Attributes = MemberAttributes.Public;
            this.theClass.Members.Add(this.theConstructor);
        }