public override GeneratedContractsBundle Generate()
        {
            var bundle = new GeneratedContractsBundle();

            foreach (var contractDescriptor in ContractsMap.Values)
            {
                var contractName = contractDescriptor.XdrContractType.Name;
                bundle.Add(new GeneratedContractFile($"{CaseConversionUtils.ConvertPascalCaseToKebabCase(contractName)}.js", GenerateContractFile(contractDescriptor, contractName)));
                bundle.Add(new GeneratedContractFile($"{CaseConversionUtils.ConvertPascalCaseToKebabCase(contractName + "Serializer")}.js", GenerateSerializerFile(contractDescriptor, contractName)));
            }
            var builder = new StringBuilder("import xdrConverter from '../serialization/xdr-converter'");
            var exports = new List <string>();

            foreach (var file in bundle.Files)
            {
                var fileName  = file.FileName;
                var className = CaseConversionUtils.ConvertKebabCaseToPascalCase(fileName.Split('.')[0]);
                exports.Add(className);
                builder.Append($"\nimport {className} from './{fileName}'");
            }
            builder.Append("\n");
            foreach (var export in exports)
            {
                if (export.EndsWith("Serializer"))
                {
                    builder.Append($"\nxdrConverter.registerSerializer({export.Replace("Serializer", string.Empty)}.name, {export})");
                }
            }
            builder.Append($"\n\nexport {{\n{string.Join(",\n", exports)}\n}}");
            bundle.Add(new GeneratedContractFile("index.js", builder.ToString()));
            return(bundle);
        }
        private string GenerateIndexFile(GeneratedContractsBundle bundle)
        {
            var builder      = new StringBuilder();
            var exports      = new List <string>();
            var initializers = new List <string>();

            foreach (var file in bundle.Files)
            {
                var fileName  = file.FileName;
                var className = CaseConversionUtils.ConvertKebabCaseToPascalCase(fileName.Split('.')[0]);
                if (!className.EndsWith("Serializer"))
                {
                    exports.Add(className);
                }
                else
                {
                    initializers.Add(className);
                }
                builder.Append($"const {className} = require('./{fileName}')\n");
            }
            builder.Append("\nfunction registerSerializers(xdrConverter) {");
            foreach (var initializer in initializers)
            {
                builder.Append($"\n{Padding}xdrConverter.registerSerializer({initializer.Replace("Serializer", string.Empty)}, {initializer})");
            }
            builder.Append("\n}");
            builder.Append($"\n\nmodule.exports = {{\n{Padding}registerSerializers,\n{string.Join(",\n", exports.Select(s => Padding + s))}\n}}");
            return(builder.ToString());
        }
        public override GeneratedContractsBundle Generate()
        {
            var bundle = new GeneratedContractsBundle();

            foreach (var contractDescriptor in ContractsMap.Values)
            {
                bundle.Add(new GeneratedContractFile(GetSerializerClassName(contractDescriptor) + ".cs", GenerateSerializerFile(contractDescriptor)));
            }
            return(bundle);
        }
        public override GeneratedContractsBundle Generate()
        {
            var bundle = new GeneratedContractsBundle();

            EnumDefinitions = new HashSet <Type>();
            foreach (var contractDescriptor in ContractsMap.Values)
            {
                var contractName = contractDescriptor.XdrContractType.Name;
                bundle.Add(new GeneratedContractFile($"{GetContractFileName(contractDescriptor.XdrContractType)}.js", GenerateContractFile(contractDescriptor, contractName)));
                bundle.Add(new GeneratedContractFile($"{GetContractFileName(contractDescriptor.XdrContractType, "Serializer")}.js", GenerateSerializerFile(contractDescriptor, contractName)));
            }
            foreach (var enumDefinition in EnumDefinitions)
            {
                bundle.Add(new GeneratedContractFile($"{GetContractFileName(enumDefinition)}.js", GenerateEnumFile(enumDefinition)));
            }

            bundle.Add(new GeneratedContractFile("index.js", GenerateIndexFile(bundle)));
            return(bundle);
        }