Initial commit
This commit is contained in:
84
Creator/SetupTmplCode.cs
Normal file
84
Creator/SetupTmplCode.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Katteker;
|
||||
|
||||
namespace KattekerCreator
|
||||
{
|
||||
public partial class SetupTmpl
|
||||
{
|
||||
public string AppName
|
||||
{
|
||||
get => string.IsNullOrWhiteSpace(ReleaseChannel) ? _appName : $"{_appName}_{ReleaseChannel}";
|
||||
set => _appName = value;
|
||||
}
|
||||
|
||||
public string Executable { get; set; }
|
||||
public string CompanyName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public SemanticVersion Version { get; set; }
|
||||
public Version LegacyVersion => Version.ToSystemVersion();
|
||||
public string HelpUrl { get; set; }
|
||||
public long InstallSize { get; set; }
|
||||
public bool IsManaged { get; set; }
|
||||
public string IconPath { get; set; }
|
||||
public string SourcePath { get; set; } = string.Empty;
|
||||
public List<PhysicalFile> Files { get; set; } = new List<PhysicalFile>();
|
||||
private IEnumerable<string> Directories => DirectoriesToCreate();
|
||||
public string UserInterface { get; set; }
|
||||
public string OutFile { get; set; }
|
||||
public string UninstallIcon { get; set; }
|
||||
public string ReleaseChannel { get; set; }
|
||||
|
||||
private readonly List<DirSplit> _directoriesList = new List<DirSplit>();
|
||||
private string _appName;
|
||||
|
||||
private IEnumerable<string> DirectoriesToCreate()
|
||||
{
|
||||
foreach (var physicalFile in Files)
|
||||
{
|
||||
var dirSplit = new DirSplit(physicalFile.TargetPath);
|
||||
if (dirSplit.SplitCount > 1 && !_directoriesList.Contains(dirSplit))
|
||||
{
|
||||
_directoriesList.Add(dirSplit);
|
||||
}
|
||||
}
|
||||
|
||||
return _directoriesList.Select(x=> x.ToString());
|
||||
}
|
||||
|
||||
private class DirSplit
|
||||
{
|
||||
private const char SplitChar = '\\';
|
||||
|
||||
private readonly string[] _splits;
|
||||
|
||||
public int SplitCount => _splits.Length;
|
||||
|
||||
public DirSplit(string path)
|
||||
{
|
||||
_splits = path.Split(SplitChar);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Join(SplitChar.ToString(), _splits.Take(_splits.Length - 1));
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return string.Equals(ToString(), obj?.ToString());
|
||||
}
|
||||
|
||||
protected bool Equals(DirSplit other)
|
||||
{
|
||||
return Equals(_splits, other._splits);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (_splits != null ? _splits.GetHashCode() : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user