54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Matrix42.Extensions.Scaffolder.Core.Project;
|
|
|
|
public class ProjectDefinition
|
|
{
|
|
/// <summary>
|
|
/// E.g. "Services", "BizLogic", etc.
|
|
/// If empty, project name will be equal to ExtensionNamespace.
|
|
/// </summary>
|
|
public string Prefix { get; set; } = string.Empty;
|
|
|
|
public RuntimeTargets Runtimes { get; set; }
|
|
|
|
/// <summary>
|
|
/// Combination of functionality flags: WebApi, Engine, Behavior, Connector, Custom.
|
|
/// </summary>
|
|
public ProjectFunctionality Functionality { get; set; } = ProjectFunctionality.None;
|
|
|
|
public string Display => $"Prefix: {Prefix} - Runtimes: {Runtimes} - Functionality: {Functionality}";
|
|
|
|
public string GetProjectName(string extensionNamespace)
|
|
{
|
|
var pfx = Prefix?.Trim();
|
|
return string.IsNullOrWhiteSpace(pfx)
|
|
? extensionNamespace
|
|
: $"{extensionNamespace}.{pfx}";
|
|
}
|
|
|
|
public string GetNamespace(string extensionNamespace) => GetProjectName(extensionNamespace);
|
|
|
|
public bool DoesSupportAllRuntimes() => Runtimes.HasFlag(RuntimeTargets.All);
|
|
|
|
public string GetRuntimeIdentifiers()
|
|
{
|
|
if (DoesSupportAllRuntimes())
|
|
{
|
|
return "netstandard2.0";
|
|
}
|
|
|
|
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);
|
|
}
|
|
} |