Beispiel #1
0
        private void AppendBody(StringAppender appender, YuScriptCreateSetting setting)
        {
            var nameSpace = setting.NameSpace;

            appender.AppendLine("namespace " + nameSpace);
            appender.AppendLine("{");
            appender.ToRight();
            var scriptId    = setting.ScriptId;
            var inheritText = setting.IsAotuCreateInterface ? ": I" + scriptId : null;

            switch (setting.inherits)
            {
            case Inherits.Class:
                TryAppendAotuInterface(appender, setting);
                appender.AppendLine($"public class {scriptId} {inheritText}");
                break;

            case Inherits.AbstractClass:
                TryAppendAotuInterface(appender, setting);
                appender.AppendLine($"public abstract class {scriptId} {inheritText}");
                break;

            case Inherits.Enum:
                appender.AppendLine($"public enum {scriptId} : byte");
                break;

            case Inherits.Interface:
                appender.AppendLine($"public interface {scriptId}");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (!string.IsNullOrEmpty(setting.Inherit) &&
                setting.inherits != Inherits.Enum)
            {
                appender.Append("        : " + setting.Inherit);
            }

            appender.AppendLine("{");
            appender.AppendLine("}");
            appender.ToLeft();
            appender.AppendLine("}");
            appender.AppendLine();

            if (!string.IsNullOrEmpty(setting.PreComplie))
            {
                appender.AppendLine("#endif");
            }
        }