Exemplo n.º 1
0
        /// <summary>
        /// Adds a property line inside an entity or complex type object
        /// </summary>
        /// <param name="prop">property</param>
        private void AddProperties(OdcmProperty prop)
        {
            if (prop.LongDescription != null || prop.Description != null)
            {
                List <string> multiLineDescriptions = SplitString(prop.GetSanitizedLongDescription());
                if (multiLineDescriptions.Count() == 1)
                {
                    sb.AppendLine($"{NamespaceIndent}{TabSpace}// {multiLineDescriptions.First()}");
                }
                else
                {
                    sb.AppendLine($"{NamespaceIndent}{TabSpace}/**");
                    foreach (var descriptionLine in multiLineDescriptions)
                    {
                        sb.AppendLine($"{NamespaceIndent}{TabSpace} * {descriptionLine}");
                    }

                    sb.AppendLine($"{NamespaceIndent}{TabSpace} */");
                }
            }

            var typeName = GetFullyQualifiedTypeScriptTypeName(prop.GetTypeString(), prop.Projection.Type.Namespace.GetNamespaceName());

            if (prop.IsNullable)
            {
                typeName = $"NullableOption<{typeName}>";
            }

            sb.AppendLine($"{NamespaceIndent}{TabSpace}{prop.Name}?: {typeName};");
        }