Beispiel #1
0
        public override string ToString()
        {
            StringBuilder csMethod = new StringBuilder(ScriptUtils.GetAccessLevel(MethodAccessLevel));

            switch (MethodKeyWord)
            {
            case CsKeyWord.Default:
            case CsKeyWord.Const:
            case CsKeyWord.InterfaceMethod:
                break;

            case CsKeyWord.Virtual:
                csMethod.Append(" virtual");
                break;

            case CsKeyWord.Override:
                csMethod.Append(" override");
                break;

            case CsKeyWord.Abstract:
                csMethod.Append(" abstract");
                break;

            case CsKeyWord.Static:
                csMethod.Append(" static");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            csMethod.Append($" {(string.IsNullOrWhiteSpace(MethodReturnType) ? "void" : MethodReturnType)} {MethodName}");
            if (GenericTypesName.Count > 0)
            {
                csMethod.Append($"<{string.Join(", ", GenericTypesName)}>");
            }
            csMethod.Append("(");
            if (Parameters.Count > 0)
            {
                csMethod.Append(string.Join(", ", Parameters));
            }
            csMethod.Append(")");
            foreach (IGenericPair <string, string> item in GenericWhereCondition)
            {
                csMethod.Append($"\nwhere {item.x} : {item.y}");
            }
            if (MethodKeyWord == CsKeyWord.Abstract || MethodKeyWord == CsKeyWord.InterfaceMethod)
            {
                csMethod.Append(";");
            }
            else
            {
                csMethod.Append("\n{\n");
                csMethod.Append(string.Join("\n", Lines.Select(s => $"\t{s}")));
                csMethod.Append("\n}");
            }
            return(csMethod.ToString());
        }
Beispiel #2
0
        public override string GetFileContent(string currentIndentation)
        {
            StringBuilder csClass = new StringBuilder($"{currentIndentation}{ScriptUtils.GetAccessLevel(CsAccessLevel)} class {CsName}");

            if (GenericTypesName.Count > 0)
            {
                csClass.Append($"<{string.Join(", ", GenericTypesName)}>");
            }
            if (InheritedTypesName.Count > 0)
            {
                csClass.Append($" : {string.Join(", ", InheritedTypesName)}");
            }
            foreach (IGenericPair <string, string> item in GenericWhereCondition)
            {
                csClass.Append($"\n{currentIndentation}where {item.x} : {item.y}");
            }
            csClass.Append($"\n{currentIndentation}{{\n");
            foreach (CsProperty property in Properties)
            {
                csClass.Append($"{property.ToString().InsertAtStartOfEachLine($"{currentIndentation}\t")}\n");
            }
            if (Constructors.Count > 0 && Properties.Count > 0)
            {
                csClass.Append("\n");
            }
            foreach (CsConstructor constructor in Constructors)
            {
                csClass.Append($"{constructor.ToString().InsertAtStartOfEachLine($"{currentIndentation}\t")}\n");
            }
            if (Indexers.Count > 0 && (Properties.Count > 0 || Constructors.Count > 0))
            {
                csClass.Append("\n");
            }
            foreach (CsIndexer indexer in Indexers)
            {
                csClass.Append($"{indexer.ToString().InsertAtStartOfEachLine($"{currentIndentation}\t")}\n");
            }
            if (Methods.Count > 0 && (Properties.Count > 0 || Constructors.Count > 0 || Indexers.Count > 0))
            {
                csClass.Append("\n");
            }
            foreach (CsMethod method in Methods)
            {
                csClass.Append($"{method.ToString().InsertAtStartOfEachLine($"{currentIndentation}\t")}\n");
            }
            csClass.Append($"{currentIndentation}}}\n");
            return(csClass.ToString());
        }
Beispiel #3
0
        public override string ToString()
        {
            StringBuilder csProperty = new StringBuilder(ScriptUtils.GetAccessLevel(PropertyAccessLevel));

            switch (KeyWord)
            {
            case CsKeyWord.Default:
                break;

            case CsKeyWord.Const:
                csProperty.Append(" const");
                break;

            case CsKeyWord.Virtual:
                csProperty.Append(" virtual");
                break;

            case CsKeyWord.Override:
                csProperty.Append(" override");
                break;

            case CsKeyWord.Abstract:
                csProperty.Append(" abstract");
                break;

            case CsKeyWord.Static:
                csProperty.Append(" static");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            csProperty.Append($" {PropertyType} {PropertyName}{GetterSetter}");
            if (string.IsNullOrWhiteSpace(DefaultValue))
            {
                if (GetterSetter.Getter == CsAccessLevel.Default && GetterSetter.Setter == CsAccessLevel.Default)
                {
                    csProperty.Append(";");
                }
            }
            else
            {
                csProperty.Append($" = {DefaultValue};");
            }
            return(csProperty.ToString());
        }
Beispiel #4
0
 public override string ToString()
 {
     return($"{ScriptUtils.GetAccessLevel(IndexerAccessLevel)} {IndexerReturnType} this[{string.Join(", ", Parameters)}]{GetterSetter}");
 }
Beispiel #5
0
 public override string GetFileContent(string currentIndentation)
 {
     return($"{currentIndentation}{ScriptUtils.GetAccessLevel(CsAccessLevel)} enum {CsName}\n{currentIndentation}{{" +
            $"\n{currentIndentation}\t{string.Join($",\n{currentIndentation}\t", Enums.Select(s => s.y == null ? s.x : $"{s.x} = {s.y}"))}" +