/// <summary> /// Returns a comma separated list of arguments to be passed into a method or constructor based on the <paramref name="parameters"/> argument. /// </summary> /// <typeparam name="TModel"></typeparam> /// <typeparam name="TParameterModel"></typeparam> /// <param name="template"></param> /// <param name="parameters"></param> /// <returns></returns> public static string GetArguments <TModel, TParameterModel>(this CSharpTemplateBase <TModel> template, IEnumerable <TParameterModel> parameters) where TParameterModel : IHasName, IHasTypeReference { return(string.Join(", ", parameters.Select(x => $"{x.Name}"))); }
/// <summary> /// Creates a fully qualified namespace based on the OutputTarget location and the <paramref name="additionalFolders"/>. /// </summary> /// <param name="template"></param> /// <param name="additionalFolders"></param> /// <returns></returns> public static string GetNamespace(this CSharpTemplateBase <object> template, params string[] additionalFolders) { return(string.Join(".", new[] { template.OutputTarget.GetNamespace() }.Concat(additionalFolders))); }
/// <summary> /// Returns a comma separated list of parameters for a method or constructor based on the <paramref name="parameters"/> argument. /// </summary> /// <param name="template"></param> /// <param name="parameters"></param> /// <typeparam name="TModel"></typeparam> /// <typeparam name="TParameterModel"></typeparam> /// <returns></returns> public static string GetParameters <TModel, TParameterModel>(this CSharpTemplateBase <TModel> template, IEnumerable <TParameterModel> parameters) where TParameterModel : IHasName, IHasTypeReference { return(string.Join(", ", parameters.Select(x => $"{template.GetTypeName(x)} {x.Name.ToCamelCase(true)}"))); }
/// <summary> /// Creates a fully qualified namespace based on the OutputTarget location and the parent folders of this template's model as described in the designer. /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="template"></param> /// <param name="additionalFolders"></param> /// <returns></returns> public static string GetNamespace <TModel>(this CSharpTemplateBase <TModel> template, params string[] additionalFolders) where TModel : IHasFolder { return(string.Join(".", new [] { template.OutputTarget.GetNamespace() }.Concat(template.Model.GetParentFolderNames()).Concat(additionalFolders))); }