public string GetFilePath(HasMembersBase builder)
    {
        var featurePath = GetFeaturePath(builder.ProjectBuilder, builder.FeatureBuilder);
        var fileName    = $"{builder.Name}.cs";

        var filePath = Path.Combine(featurePath, fileName);

        return(filePath);
    }
 private List <string> GetAdditionalUsings(HasMembersBase builder)
 {
     return(builder
            .AdditionalUsingStatements
            .Select(z => $"using {z};")
            .OrderBy(z => z)
            .Distinct()
            .ToList());
 }
    private string GetMethodContentViaNotImplemented(HasMembersBase builder, MethodDescription methodDescription)
    {
        var returnType    = methodDescription.ReturnType.GetTypeName();
        var methodName    = methodDescription.Name;
        var parameterText = GetParameterTextWithTypes(methodDescription.Parameters);

        return($@"public {returnType} {methodName}({parameterText})
{{
    throw new NotImplementedException();
}}");
    }
    private string GetFieldsText(HasMembersBase builder)
    {
        var fields = new List <string>();

        foreach (var delegateTo in builder.DelegatesImplTo)
        {
            fields.Add(
                $"private readonly {delegateTo.FullTypeInfo.Name} {delegateTo.FullTypeInfo.Name.GetFieldName()};");
        }

        return(string.Join(Environment.NewLine, fields));
    }
    private string GetInheritsText(HasMembersBase builder)
    {
        if (builder.ImplementList.Count == 0)
        {
            return(String.Empty);
        }
        var implementsString = builder
                               .ImplementList
                               .Select(z => z.Name)
                               .StringJoin(", ");

        return($" : {implementsString}");
    }
    private object GetmethodContentViaDelegation(
        HasMembersBase builder,
        DelegatesToOptions delegatesToOptions,
        MethodDescription methodDescription)
    {
        var returnType    = methodDescription.ReturnType.GetTypeName();
        var methodName    = methodDescription.Name;
        var parameterText = GetParameterTextWithTypes(methodDescription.Parameters);

        return($@"public {returnType} {methodName}({parameterText})
{{
    return {delegatesToOptions.FieldName}.{methodDescription.Name}({GetParameterTextWithoutTypes(methodDescription.Parameters)});
}}");
    }
    private string GetMethodsContent(HasMembersBase builder)
    {
        var methodsToImplement = new List <MethodDescription>();
        var content            = string.Empty;

        foreach (var delegateTo in builder.DelegatesImplTo)
        {
            if (builder.GetType() == typeof(WebApiBuilder))
            {
                foreach (var delegateMethodDesc in delegateTo
                         .Methods
                         .Where(z => z.IsPublic)
                         .ExceptObjectBaseMethods()
                         )
                {
                    if (methodsToImplement.Any(z => z.Name == delegateMethodDesc.Name))
                    {
                        continue;
                    }
                    methodsToImplement.Add(delegateMethodDesc);
                    content += $"[HttpPost(\"{delegateMethodDesc.Name.ToLower()}\")]";
                    content += Environment.NewLine +
                               GetmethodContentViaDelegation(builder, delegateTo, delegateMethodDesc);
                }
            }
            else
            {
                foreach (var delegateMethodDesc in delegateTo
                         .Methods
                         .Where(z => z.IsPublic)
                         .ExceptObjectBaseMethods()
                         )
                {
                    if (methodsToImplement.Any(z => z.Name == delegateMethodDesc.Name))
                    {
                        continue;
                    }
                    methodsToImplement.Add(delegateMethodDesc);
                    content += Environment.NewLine +
                               GetmethodContentViaDelegation(builder, delegateTo, delegateMethodDesc);
                }
            }
        }

        foreach (var implement in builder.ImplementList)
        {
            foreach (var implementMethodDesc in implement.MethodDescriptions)
            {
                if (methodsToImplement.Any(z => z.Name == implementMethodDesc.Name))
                {
                    continue;
                }
                methodsToImplement.Add(implementMethodDesc);
                content += Environment.NewLine + GetMethodContentViaNotImplemented(builder, implementMethodDesc);
            }
        }

        if (builder is ApiDefBuilder apiDefBuilder)
        {
            foreach (var methodDesc in apiDefBuilder
                     .TalksTo
                     .MethodDescriptions
                     .Where(z => z.IsPublic)
                     .ExceptObjectBaseMethods())
            {
                content += $"[Post(\"{apiDefBuilder.TalksTo.GetUrl()}{methodDesc.Name.ToCamelCase()}\")]";
                content += Environment.NewLine;
                content +=
                    $"{methodDesc.ReturnType.GetTypeName()} {methodDesc.Name}({GetParameterTextWithTypes(methodDesc.Parameters)});";
                content += Environment.NewLine;
            }
        }


        return(content);
    }