67 lines
1.6 KiB
C#
67 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Matrix42.Extensions.Scaffolder.Wizard
|
|
{
|
|
public enum ProjectType
|
|
{
|
|
WebApi,
|
|
Contracts,
|
|
BizLogic,
|
|
Custom
|
|
}
|
|
|
|
public class ProjectDefinition
|
|
{
|
|
public ProjectType Type { get; set; }
|
|
public string Prefix { get; set; } = string.Empty; // custom for Custom type, otherwise derived
|
|
public RuntimeTargets Runtimes { get; set; }
|
|
|
|
public string EffectivePrefix
|
|
{
|
|
get
|
|
{
|
|
if (Type == ProjectType.Custom)
|
|
return Prefix;
|
|
|
|
switch (Type)
|
|
{
|
|
case ProjectType.WebApi:
|
|
return string.IsNullOrWhiteSpace(Prefix) ? "Services" : Prefix;
|
|
case ProjectType.Contracts:
|
|
return string.IsNullOrWhiteSpace(Prefix) ? "Contracts" : Prefix;
|
|
case ProjectType.BizLogic:
|
|
return string.IsNullOrWhiteSpace(Prefix) ? "BizLogic" : Prefix;
|
|
default:
|
|
return Prefix;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string Display => $"{Type} - Prefix: {EffectivePrefix} - Runtimes: {Runtimes}";
|
|
|
|
public string GetProjectName(string extensionNamespace)
|
|
{
|
|
var pfx = EffectivePrefix?.Trim();
|
|
return string.IsNullOrWhiteSpace(pfx)
|
|
? extensionNamespace
|
|
: $"{extensionNamespace}.{pfx}";
|
|
}
|
|
|
|
public string GetNamespace(string extensionNamespace) => GetProjectName(extensionNamespace);
|
|
|
|
public string GetRuntimeIdentifiers()
|
|
{
|
|
if (Runtimes.HasFlag(RuntimeTargets.All))
|
|
return "win-x64;linux-x64";
|
|
|
|
var list = new List<string>();
|
|
if (Runtimes.HasFlag(RuntimeTargets.Win) || Runtimes.HasFlag(RuntimeTargets.WinCore))
|
|
list.Add("win-x64");
|
|
if (Runtimes.HasFlag(RuntimeTargets.LinuxCore))
|
|
list.Add("linux-x64");
|
|
|
|
return string.Join(";", list);
|
|
}
|
|
}
|
|
}
|