2 using System.Collections.Generic;
 
    5 namespace CodeGen.generators
 
   16         protected static bool UseTabs = 
true;
 
   25             var data = 
new Dictionary<string, string>();
 
   26             UseTabs = !pkg.UseSpaces;
 
   27             foreach (var 
@class in pkg.Classes)
 
   29                 if (
@class?.Name != null)
 
   30                     data[
@class.Name] = GenerateClass(
@class) + 
'\n';
 
   50         protected abstract string GenerateClass(
Class @class);
 
   57         public abstract string GenerateField(
Field field);
 
   64         public abstract string GenerateMethod(
Method method);
 
   82             for (var i = 0; i < pkg.Classes?.Length; i++)
 
   83                 NormalizeClass(ref pkg.Classes[i]);
 
   84             for (var i = 0; i < pkg.Packages?.Length; i++)
 
   85                 if (pkg.Packages[i] != pkg)
 
   86                     NormalizePackage(ref pkg.Packages[i]);
 
   99             for (var i = 0; i < 
@class.Fields?.Length; i++)
 
  100                 NormalizeField(ref 
@class.Fields[i]);
 
  101             for (var i = 0; i < 
@class.Methods?.Length; i++)
 
  102                 NormalizeMethod(ref 
@class.Methods[i]);
 
  103             for (var i = 0; i < 
@class.Classes?.Length; i++)
 
  104                 NormalizeClass(ref 
@class.Classes[i]);
 
  115             field.Type = NormalizeType(field.Type);
 
  126             method.Type = NormalizeType(method.Type);
 
  127             for (var i = 0; i < method.Parameters?.Length; i++)
 
  128                 NormalizeParameter(method.Parameters[i]);
 
  139             parameter.Type = NormalizeType(parameter.
Type);
 
  148         protected abstract string NormalizeType(
string type);
 
  156         private string[] AccessModifiers { 
get; } = {
"", 
"public", 
"private", 
"protected", 
"default"};
 
  167             var isInvalid = string.IsNullOrWhiteSpace(field.Name);
 
  168             isInvalid |= string.IsNullOrWhiteSpace(field.Type);
 
  169             isInvalid |= string.IsNullOrWhiteSpace(field.Type);
 
  170             isInvalid |= field.Name.Any(char.IsWhiteSpace);
 
  171             isInvalid |= field.Type.Any(char.IsWhiteSpace);
 
  172             if (field.
Access == null) 
return !isInvalid;
 
  173             isInvalid |= field.Access.Any(char.IsWhiteSpace);
 
  174             isInvalid |= !AccessModifiers.Any(field.Access.Equals);
 
  207         private readonly 
int _indentSize;
 
  221             Extension = extension;
 
  224             _indentSize = indentSize;
 
  243                 new Class {Name = 
"Fruit"},
 
  263                             Default = 
"\"Golden\"",
 
  294                             Access = 
"protected",
 
  297                             Name = 
"getSizeValue" 
  303                             Name = 
"getColorName",
 
  345         public static readonly Dictionary<string, Languange> Languanges = 
new Dictionary<string, Languange>
 
  369             return tabs ? 
"\t" : 
new string(
' ', tabStop);
 
  379         public static string ShiftCode(
string code, 
int num, 
string indent)
 
  381             indent = string.Concat(Enumerable.Repeat(indent, num));
 
  382             return indent + code.Replace(
"\n", 
"\n" + indent);
 
  396             else if (lang == 
"c#" || lang == 
"cs")
 
  400             else if (lang == 
"yml")
 
  404             else if (lang == 
"c++")
 
  420             name = NormalizeLang(name);
 
  424                 lang = Languanges[name];
 
  428                 throw new IndexOutOfRangeException(
"this language doesn't exist");
 
virtual Method NormalizeMethod(ref Method method)
Method normalizer: normalizes method 
static Normalizer GetNormalizer()
Method for getting a singleton 
The class that describes programming language and has a generator for it 
The structure that describes class. Contains name, array of fields, methods and subclasses, parent class name, access specifier. Overrides ToString() method. 
string Type
Represents the type of the variable. Type: string 
virtual string GetIndent()
Gets indentation of current generator 
static string GetIndent(bool tabs, int tabStop)
Creates indent using given parameters 
The structure that describes package. Contains classes and subpackages 
Languange(Generator generator, string extension="", string comment="", Normalizer normalizer=null, int indentSize=4)
Constructor for language, used to avoid struct initializers 
Generator for JavaScript ES6 
static Normalizer GetNormalizer()
Method for getting a singleton 
static Normalizer GetNormalizer()
Method for getting a singleton 
readonly string Comment
Holds comment format. Field is read only 
Holds the configuration of generator 
virtual Package NormalizePackage(ref Package pkg)
Package normalizer: normalizes package with classes and subpackages 
Dictionary< string, string > Generate(Package pkg)
Package generator: generates package with classes and subpackages from given package object ...
Normalizer for Visual Basic
virtual bool FieldIsValid(Field field)
Checks if field is valid 
Interface of language normalizer: normalizes package data according to specified language ...
virtual Field NormalizeField(ref Field field)
Field normalizer: normalizes field 
static string NormalizeLang(string lang)
Converts given language into language which is used for identification of generator ...
static Languange GetLanguage(string name)
Creates generator if it exists, else throws an error 
Generator for Visual Basic 
readonly Generator Generator
Holds the generator of the language. Field is read only 
static string ShiftCode(string code, int num, string indent)
Shifts code using given parameters 
string Access
Represents access level of the field. Type: string 
Interface of language generator 
readonly string Extension
Holds the extension of the file. Field is read only 
virtual Parameter NormalizeParameter(Parameter parameter)
Parameter normalizer: normalizes parameter 
virtual Class NormalizeClass(ref Class @class)
Class normalizer: normalizes class with fields, methods and subclasses 
The structure that describes method. Contains name, return type, access level, const and static prope...
The structure that describes parameter. Inherits from Variable 
readonly Normalizer Normalizer
Holds language normalizer. Field is read only 
The structure that describes field. Contains access, const and static properties. Inherits from Varia...