// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
namespace WixToolset.Core
{
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using WixToolset.Extensibility.Services;
///
/// The WiX Toolset harvester core.
///
public class HarvesterCore : IHarvesterCore
{
public IMessaging Messaging { get; set; }
///
/// Gets or sets the value of the extension argument passed to heat.
///
/// The extension argument.
public string ExtensionArgument { get; set; }
///
/// Gets or sets the value of the root directory that is being harvested.
///
/// The root directory being harvested.
public string RootDirectory { get; set; }
///
/// Create an identifier based on passed file name
///
/// File name to generate identifer from
///
public string CreateIdentifierFromFilename(string filename)
{
return Common.GetIdentifierFromName(filename);
}
///
/// Generate an identifier by hashing data from the row.
///
/// Three letter or less prefix for generated row identifier.
/// Information to hash.
/// The generated identifier.
[SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.InvalidOperationException.#ctor(System.String)")]
public string GenerateIdentifier(string prefix, params string[] args)
{
return Common.GenerateIdentifier(prefix, args);
}
///
/// Resolves a file's path if the Wix.File.Source value starts with "SourceDir\".
///
/// The Wix.File.Source value with "SourceDir\".
/// The full path of the file.
public string ResolveFilePath(string fileSource)
{
if (fileSource.StartsWith("SourceDir\\", StringComparison.Ordinal))
{
string file = Path.GetFullPath(this.RootDirectory);
if (File.Exists(file))
{
return file;
}
else
{
fileSource = fileSource.Substring(10);
fileSource = Path.Combine(Path.GetFullPath(this.RootDirectory), fileSource);
}
}
return fileSource;
}
}
}