Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
<Project>{9E8B79ED-9C17-485B-B1F9-8D33D8BB4BD2}</Project>
<Name>Endjin.Templify.Domain</Name>
</ProjectReference>
<ProjectReference Include="..\Endjin.Templify.WizardFramework\Endjin.Templify.WizardFramework.csproj">
<Project>{D8F709BA-1E52-48FB-A917-7C3A40445F7F}</Project>
<Name>Endjin.Templify.WizardFramework</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\app-icon.ico" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Endjin.Templify.Client.ViewModel
using Endjin.Templify.Domain.Framework;
using Endjin.Templify.Domain.Framework.Threading;
using Endjin.Templify.Domain.Infrastructure;
using Endjin.Templify.WizardFramework;

#endregion

Expand Down Expand Up @@ -250,7 +251,11 @@ private void ExecutePackageComplete(RunWorkerCompletedEventArgs e)
private void ExecutePackageCore(Package package)
{
this.packageDeploymentProcessor.Execute(package);
this.packageProcessor.Process(this.CommandOptions.Path, this.Name);

// TODO: Due to the WizardFramework being a WinForm, the WPF app does not show anything :-(
this.ExecuteWizard(package);

this.packageProcessor.Process(this.CommandOptions.Path, this.Name, package.Manifest.Configuration);
}

private void Initialise()
Expand All @@ -269,5 +274,24 @@ private void RetrievePackages()
{
this.Packages = new PackageCollection(this.packageRepository.FindAll());
}

private void ExecuteWizard(Package package)
{
// TODO: Run the wizard to collect the token info
// Instantiate the command list
var cmdList = new CommandList();

// Add the WizardCommand objects in order to the list to provide
// the application workflow
cmdList.Add(new PackageConfigurationDataWizardFormCommand(package.Manifest.Configuration));

// The wizard simply uses a flow of objects in order until we
// reach the last command, so loop until that condition is
// detected
while (cmdList.CmdPointer > -1 && !cmdList.IsLastCommand())
{
cmdList.ExecuteNext();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
#region Using Directives

using System;
using System.Collections.Generic;

using Endjin.Templify.Domain.Domain.Packages;

#endregion

public interface IPackageProcessor
{
void Process(string path, string name);
void Process(string path, string name, List<PackageConfigurationData> tokens);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
namespace Endjin.Templify.Domain.Contracts.Packager.Tokeniser
{
using System.Collections.Generic;

using Endjin.Templify.Domain.Domain.Packages;

public interface ITemplateTokeniser
{
void TokeniseFileContent(string file, string token);
void TokeniseFileContent(string file, List<PackageConfigurationData> tokens);

void TokeniseDirectoryAndFilePaths(string file, string token);
void TokeniseDirectoryAndFilePaths(string file, List<PackageConfigurationData> tokens);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public PackageProcessor(
this.templateTokeniser = templateTokeniser;
}

public void Process(string path, string name)
public void Process(string path, string name, List<PackageConfigurationData> tokens)
{
this.ProcessFiles(path, name);
this.ProcessFiles(path, tokens);
this.ProcessDirectories(path);
}

Expand All @@ -67,28 +67,28 @@ private void ProcessDirectories(string path)
}
}

private void ProcessFiles(string path, string name)
private void ProcessFiles(string path, List<PackageConfigurationData> tokens)
{
var files = this.artefactProcessor.RetrieveFiles(path);
this.ProcessFileContents(files, name);
this.ProcessDirectoryAndFilePaths(files, name);

this.ProcessFileContents(files, tokens);
this.ProcessDirectoryAndFilePaths(files, tokens);
}

private void ProcessDirectoryAndFilePaths(IEnumerable<string> files, string name)
private void ProcessDirectoryAndFilePaths(IEnumerable<string> files, List<PackageConfigurationData> tokens)
{
int fileCount = files.Count();
int progress = 0;

foreach (var file in files)
{
this.templateTokeniser.TokeniseDirectoryAndFilePaths(file, name);
this.templateTokeniser.TokeniseDirectoryAndFilePaths(file, tokens);
this.progressNotifier.UpdateProgress(ProgressStage.TokenisePackageStructure, fileCount, progress);
progress++;
}
}

private void ProcessFileContents(IEnumerable<string> files, string name)
private void ProcessFileContents(IEnumerable<string> files, List<PackageConfigurationData> tokens)
{
var filteredFiles = this.binaryFileFilter.Filter(files);

Expand All @@ -97,7 +97,7 @@ private void ProcessFileContents(IEnumerable<string> files, string name)

foreach (var file in filteredFiles)
{
this.templateTokeniser.TokeniseFileContent(file, name);
this.templateTokeniser.TokeniseFileContent(file, tokens);
this.progressNotifier.UpdateProgress(ProgressStage.TokenisePackageContents, fileCount, progress);
progress++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ namespace Endjin.Templify.Domain.Domain.Packager.Tokeniser
{
#region Using Directives

using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Text.RegularExpressions;

using Endjin.Templify.Domain.Contracts.Packager.Processors;
using Endjin.Templify.Domain.Contracts.Packager.Tokeniser;
using Endjin.Templify.Domain.Domain.Packages;
using Endjin.Templify.Domain.Infrastructure;

#endregion
Expand All @@ -24,22 +26,43 @@ public TemplateTokeniser(IRenameFileProcessor renameFileProcessor, IFileContentP
this.fileContentProcessor = fileContentProcessor;
}

public void TokeniseDirectoryAndFilePaths(string file, string token)
private void TokeniseDirectoriesAndFiles(string file, List<PackageConfigurationData> tokens)
{
var tokenisedName = Replace(token, file);
var tokenisedName = Replace(tokens, file);
this.renameFileProcessor.Process(file, tokenisedName);
}

public void TokeniseFileContent(string file, string token)
private void TokeniseFileContent(string file, List<PackageConfigurationData> tokens)
{
var contents = this.fileContentProcessor.ReadContents(file);
contents = Replace(token, contents);
contents = Replace(tokens, contents);
this.fileContentProcessor.WriteContents(file, contents);
}

private static string Replace(string token, string value)
private static string Replace(List<PackageConfigurationData> tokens, string value)
{
return Regex.Replace(value, Tokens.TokenName, match => token);
string replaced = value;
foreach (var token in tokens)
{
replaced = Regex.Replace(replaced, token.Token, match => token.Value);
}

// TODO: Probably need a more meaningful return value?
return replaced;
}

#region ITemplateTokeniser Members

void ITemplateTokeniser.TokeniseFileContent(string file, List<PackageConfigurationData> tokens)
{
throw new System.NotImplementedException();
}

void ITemplateTokeniser.TokeniseDirectoryAndFilePaths(string file, List<PackageConfigurationData> tokens)
{
throw new System.NotImplementedException();
}

#endregion
}
}
5 changes: 5 additions & 0 deletions Solutions/Endjin.Templify.Domain/Domain/Packages/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Manifest : IPackageMetaData
public Manifest()
{
this.Files = new List<ManifestFile>();
this.Configuration = new List<PackageConfigurationData>();
}

public string Author { get; set; }
Expand All @@ -40,5 +41,9 @@ public string Title
{
get { return this.Name + " - " + this.Version; }
}

[XmlArray]
[XmlArrayItem("Setting")]
public List<PackageConfigurationData> Configuration { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Endjin.Templify.Domain.Domain.Packages
{
using System.Xml.Serialization;

public class PackageConfigurationData
{
[XmlAttribute]
public string Token { get; set; }

[XmlText]
public string Description { get; set; }

[XmlAttribute]
public PackageConfigurationDataKind Kind { get; set; }

[XmlIgnore]
public string Value { get; set; }
}

public enum PackageConfigurationDataKind
{
text = 0,
flag = 1,
choice = 2,
password = 3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<Compile Include="Domain\Packages\Manifest.cs" />
<Compile Include="Domain\Packages\ManifestFile.cs" />
<Compile Include="Domain\Packages\Package.cs" />
<Compile Include="Domain\Packages\PackageConfigurationData.cs" />
<Compile Include="Domain\Packages\PackageMetaData.cs" />
<Compile Include="Domain\Packages\PackageProgressEventArgs.cs" />
<Compile Include="Domain\Packages\ProgressStage.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void RunPackageComplete(RunWorkerCompletedEventArgs e)
private void RunDeployPackage(Package package)
{
this.packageDeploymentProcessor.Execute(package);
this.packageProcessor.Process(this.Path, this.Name);
this.packageProcessor.Process(this.Path, this.Name, package.Manifest.Configuration);
}

private void OnProgressUpdate(object sender, PackageProgressEventArgs e)
Expand Down
33 changes: 33 additions & 0 deletions Solutions/Endjin.Templify.WizardFramework/Command.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Endjin.Templify.WizardFramework
{
using System;
using System.Collections.Generic;

using Endjin.Templify.Domain.Domain.Packages;

public class PackageConfigurationDataWizardFormCommand : FormWizardCommand
{
private List<PackageConfigurationData> settings;

public PackageConfigurationDataWizardFormCommand(List<PackageConfigurationData> Settings)
{
this.settings = Settings;
}

/// <summary>
/// Sets the form to use as the command form
/// </summary>
public override void InitialiseCommand()
{
this.CommandForm = new PackageConfigurationDataWizardForm(this.settings);
}

/// <summary>
/// Implements any cleanup required
/// </summary>
public override void CleanupCommand()
{

}
}
}
30 changes: 30 additions & 0 deletions Solutions/Endjin.Templify.WizardFramework/CommandList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace Endjin.Templify.WizardFramework
{
using System;

/// <summary>
/// Summary description for CommandList.
/// </summary>
public class CommandList : WizardCommandList
{
public CommandList()
{
//
// TODO: Add constructor logic here
//
}

public void ExecuteNext()
{

// Get the WizardCommand object to execute
WizardCommand formCmd = this[this.CmdPointer];

// Execute the WizardCommand object and set the current command
// pointer to that which is returned
this.CmdPointer = formCmd.Execute(this.CmdPointer, this.LastCmdPointer);


}
}
}
49 changes: 49 additions & 0 deletions Solutions/Endjin.Templify.WizardFramework/ConfigHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Configuration;

namespace Conchango.Fusion.InstallerWizard
{
/// <summary>
/// Summary description for ConfigHelper.
/// </summary>
public class ConfigHelper
{

private static string _wizardTitle = ConfigurationSettings.AppSettings["WizardTitle"];
private static string _wizardTitleText = ConfigurationSettings.AppSettings["WizardTitleText"];
private static string _parameterConfigFile = ConfigurationSettings.AppSettings["ParameterConfigFile"];
private static string _onlineConfigPath = ConfigurationSettings.AppSettings["CfgSrcOnlinePath"];
private static string _localConfigPath = ConfigurationSettings.AppSettings["CfgSrcLocalPath"];


private ConfigHelper()
{

}

public static string GetWizardTitle
{
get { return _wizardTitle; }
}

public static string GetWizardTitleText
{
get { return _wizardTitleText; }
}

public static string GetParameterConfigFile
{
get { return _parameterConfigFile; }
}

public static string GetOnlineConfigPath
{
get { return _onlineConfigPath; }
}

public static string GetLocalConfigPath
{
get { return _localConfigPath; }
}
}
}
Loading