Example #1
0
        public string Expand()
        {
            var isEnum = !(bool)_member.UserData["GenerateFieldType"];
            var shouldGenerateAccessModifier = (bool)_member.UserData["GenerateAccessModifier"];

            if (isEnum)
            {
                if (_member.InitExpression == null)
                {
                    return($"{_options.IndentString}{_member.Name},");
                }
                else
                {
                    var initializationExpression = _expressionFactory.GetExpression(_member.InitExpression, new System.CodeDom.Compiler.CodeGeneratorOptions()).Evaluate();
                    return(_options.IndentString + (initializationExpression == null ? $"{_member.Name}," : $"{_member.Name}={initializationExpression},"));
                }
            }

            string fieldDeclaration = $"{_member.Name.ConvertPascalCaseToCamelCase()}: {_typescriptTypeMapper.GetTypeOutput(_member.Type)};";
            var    accessModifier   = shouldGenerateAccessModifier ? _member.GetAccessModifier() : string.Empty;

            return($"{_options.IndentString}{accessModifier}{fieldDeclaration}");
        }
        public string Evaluate()
        {
            var type = _typescriptTypeMapper.GetTypeOutput(_codeExpression.Type);

            return($"{_codeExpression.Name}: {type}");
        }
Example #3
0
 public string GetTypeOutput(CodeTypeReference type)
 {
     return(_typescriptTypeMapper.GetTypeOutput(type));
 }