コード例 #1
0
ファイル: VBNamespace.cs プロジェクト: supendi/Adository
        public override string ToString()
        {
            var includedNamespaces = string.Empty;
            var nsBody             = string.Empty;

            foreach (var includeNs in IncludeNamespaces)
            {
                includedNamespaces += includeNs + NewLine;
            }

            includedNamespaces += NewLine;

            var nsBlock = new VBBlock(VBBlockStatement.Namespace, $"Namespace {Name}");

            if (!PutIncludeNamespaceOutside)
            {
                nsBlock.Statements.Add(includedNamespaces);
            }

            foreach (var cls in Classes)
            {
                nsBlock.Statements.Add(cls.ToString());
            }
            var finalSource = nsBlock.ToString();

            if (PutIncludeNamespaceOutside)
            {
                finalSource = includedNamespaces + finalSource;
            }

            return(finalSource);
        }
コード例 #2
0
ファイル: VBClass.cs プロジェクト: supendi/Adository
        public override string ToString()
        {
            var header = $"Public Sub New{CreateArgs()}";

            var ctorBlock = new VBBlock(VBBlockStatement.Sub, header);

            if (!string.IsNullOrEmpty(BaseClassConstructorParameter))
            {
                ctorBlock.Statements.Add($"MyBase.New({BaseClassConstructorParameter})");
            }

            foreach (var code in Statements)
            {
                ctorBlock.Statements.Add(code);
            }

            return(ctorBlock.ToString());
        }
コード例 #3
0
        public override string ToString()
        {
            var result       = string.Empty;
            var methodHeader = string.Empty;

            if (MethodType == MethodType.Sub)
            {
                methodHeader = $"{Modifier} {MethodType.ToString()} {Name}{CreateArgs()}";
            }
            else
            {
                methodHeader = $"{Modifier} {MethodType.ToString()} {Name}{CreateArgs()} As {Type}";
            }
            var methodBlock = new VBBlock(MethodType == MethodType.Sub ? VBBlockStatement.Sub : VBBlockStatement.Function, methodHeader);

            foreach (var statement in Statements)
            {
                methodBlock.Statements.Add(statement);
            }

            return(methodBlock.ToString());
        }
コード例 #4
0
ファイル: VBClass.cs プロジェクト: supendi/Adository
        public override string ToString()
        {
            string classHeader = (string.IsNullOrEmpty(InheritsFrom)) ? $"{Modifier} Class {Name}" : $"{Modifier} Class {Name} {NewLine} Inherits {InheritsFrom}"; //public class Brand
            var    classBlock  = new VBBlock(VBBlockStatement.Class, classHeader);

            //Generate field
            foreach (var statement in Statements)
            {
                classBlock.Statements.Add(statement);
            }

            //Generate field
            foreach (var field in Fields)
            {
                classBlock.Statements.Add(field.ToString());
            }

            //Generate properties
            foreach (var prop in Properties)
            {
                classBlock.Statements.Add(prop.ToString());
            }

            //Generate generate Constructor
            foreach (var ctor in Constructors)
            {
                ctor.Name = this.Name;
                classBlock.Statements.Add(ctor.ToString());
            }

            //Generate methods
            foreach (var method in Methods)
            {
                classBlock.Statements.Add(method.ToString());
            }

            return($"{classBlock.ToString()}");
        }