var AppName = "Application";
var AppDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var BackgroundColor = 52 << 16 | 11 << 8 | 100 << 0; // R:52 G:11 B:100
var LightForegroundText = true;
var ShowNameOnSquare150x150Logo = true;
var Square70x70LogoData = File.ReadAllBytes(@"TODO"); // TODO: image data
var Square150x150LogoData = File.ReadAllBytes(@"TODO"); // TODO: image data
var Square70x70LogoName = "70x70";
var Square150x150LogoName = "150x150";
var Square70x70LogoDirectoryPath = "Resources\\Images";
var Square150x150LogoDirectoryPath = "Resources\\Images";
var Components = ManifestService.Compile(AppName, BackgroundColor, LightForegroundText, ShowNameOnSquare150x150Logo, Square70x70LogoData, Square150x150LogoData, Square70x70LogoName, Square150x150LogoName, null, null, Square70x70LogoDirectoryPath, Square150x150LogoDirectoryPath);
// Installation
ManifestInstaller.Install(AppDirectory, Components);
var AppName = "Application";
var AppDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var Components = ManifestService.Process(AppDirectory, AppName);
ManifestUninstaller.Uninstall(AppDirectory, Components);
public static bool CompileTest()
{
var ComponentsTF1 = ManifestService.Compile("Test", (0 << 0) | (0 << 8) | (100 << 16), true, true);
var DataTF1 = ComponentsTF1[ManifestComponentType.Manifest].Data;
var HashTF1 = BitConverter.ToString(MD5.Create().ComputeHash(DataTF1));
var TF1 = HashTF1.Equals("D8-99-40-BE-4A-D9-B0-B1-E7-0B-E7-2B-F3-29-EF-59");
var ComponentsTF2 = ManifestService.Compile("Test", (0 << 0) | (0 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Png), CreateImage(ImageFormat.Gif), "70x70Logo", "150x150Logo.", "pNg", "gIf");
var DataTF2 = ComponentsTF2[ManifestComponentType.Manifest].Data.Concat(ComponentsTF2[ManifestComponentType.Square70x70Logo].Data).Concat(ComponentsTF2[ManifestComponentType.Square150x150Logo].Data).ToArray();
var HashTF2 = BitConverter.ToString(MD5.Create().ComputeHash(DataTF2));
var TF2 = HashTF2.Equals("0D-6B-D7-B2-79-52-AD-69-0F-4F-9E-E9-E5-9E-6E-98");
var ComponentsTF3 = ManifestService.Compile("Test", (0 << 0) | (0 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Png), CreateImage(ImageFormat.Gif), "70x70Logo", "150x150Logo.", "pNg", "gIf", "", "ImGs\\VeS");
var DataTF3 = ComponentsTF3[ManifestComponentType.Manifest].Data.Concat(ComponentsTF3[ManifestComponentType.Square70x70Logo].Data).Concat(ComponentsTF3[ManifestComponentType.Square150x150Logo].Data).ToArray();
var HashTF3 = BitConverter.ToString(MD5.Create().ComputeHash(DataTF3));
var TF3 = HashTF3.Equals("E2-5C-CA-82-D3-15-F6-E3-81-2A-89-4B-CB-E7-6D-A4");
var ComponentsTF4 = ManifestService.Compile("Test", (0 << 0) | (0 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Jpeg), CreateImage(ImageFormat.Gif), "70x70Logo.jpg", "150x150Logo.gif");
var DataTF4 = ComponentsTF4[ManifestComponentType.Manifest].Data.Concat(ComponentsTF4[ManifestComponentType.Square70x70Logo].Data).Concat(ComponentsTF4[ManifestComponentType.Square150x150Logo].Data).ToArray();
var HashTF4 = BitConverter.ToString(MD5.Create().ComputeHash(DataTF4));
var TF4 = HashTF4.Equals("EE-FB-CB-96-4B-D4-42-0B-D8-84-9C-1B-BD-FA-C1-73");
var ComponentsTF5 = ManifestService.Compile("Test", (222 << 0) | (1 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Gif), CreateImage(ImageFormat.Jpeg), "70x70Logo", "150x150Logo");
var DataTF5 = ComponentsTF5[ManifestComponentType.Manifest].Data.Concat(ComponentsTF5[ManifestComponentType.Square70x70Logo].Data).Concat(ComponentsTF5[ManifestComponentType.Square150x150Logo].Data).ToArray();
var HashTF5 = BitConverter.ToString(MD5.Create().ComputeHash(DataTF5));
var TF5 = HashTF5.Equals("DA-65-5B-92-83-56-7B-29-E4-81-1E-06-02-FF-57-73");
var ComponentsTF6 = ManifestService.Compile("Test", (222 << 0) | (1 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Gif), CreateImage(ImageFormat.Jpeg), "70x70Logo", "150x150Logo", null, null, "A", "");
var DataTF6 = ComponentsTF6[ManifestComponentType.Manifest].Data.Concat(ComponentsTF6[ManifestComponentType.Square70x70Logo].Data).Concat(ComponentsTF6[ManifestComponentType.Square150x150Logo].Data).ToArray();
var HashTF6 = BitConverter.ToString(MD5.Create().ComputeHash(DataTF6));
var TF6 = HashTF6.Equals("15-27-B8-B5-EF-BC-23-B4-E1-2D-96-AB-BE-BF-E9-92");
var ComponentsTF7 = ManifestService.Compile("Test", (41 << 0) | (41 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Gif), CreateImage(ImageFormat.Png), "70x70Logo", "150x150Logo", null, null, "a\\b\\c", "a\\b\\c\\d");
var DataTF7 = ComponentsTF7[ManifestComponentType.Manifest].Data.Concat(ComponentsTF7[ManifestComponentType.Square70x70Logo].Data).Concat(ComponentsTF7[ManifestComponentType.Square150x150Logo].Data).ToArray();
var HashTF7 = BitConverter.ToString(MD5.Create().ComputeHash(DataTF7));
var TF7 = HashTF7.Equals("F4-3C-BE-2C-54-77-54-F1-51-98-2E-F3-49-90-99-C1");
return TF1 && TF2 && TF3 && TF4 && TF5 && TF6 && TF7;
}
public static bool ProcessTest()
{
var Components = (ManifestComponents) ManifestService.Compile("Test",(0 << 0) | (0 << 8) | (100 << 16),true,true,CreateImage(ImageFormat.Jpeg),CreateImage(ImageFormat.Gif),"Test--70x70Logo.jpg","Test--150x150Logo.GIF");
Install(Path.GetTempPath(), Components);
Components = ManifestService.Process(Path.GetTempPath(), "Test");
var Data = Components[ManifestComponentType.Manifest].Data.Concat(Components[ManifestComponentType.Square70x70Logo].Data).Concat(Components[ManifestComponentType.Square150x150Logo].Data).ToArray();
var Hash = BitConverter.ToString(MD5.Create().ComputeHash(Data));
return Hash.Equals("01-4C-4F-6B-75-EB-05-8B-D1-C0-C1-A7-DB-B2-5C-1E");
}
public static bool DecompileTest()
{
var BackgroundColor = Convert.ToInt32("#0000FF".Substring(1), 16);
var LightForegroundText = false;
var ShowNameOnSquare150x150Logo = false;
var Square70x70LogoData = CreateImage(ImageFormat.Jpeg);
var Square150x150LogoData = CreateImage(ImageFormat.Gif);
var Square70x70LogoFormat = "jpg";
var Square150x150LogoFormat = "gif";
var Square70x70LogoName = "Test--70x70Logo";
var Square150x150LogoName = "Test--150x150Logo";
var Square70x70LogoDirectoryPath = "70x70";
var Square150x150LogoDirectoryPath = "";
var Components = ManifestService.Compile("Test", BackgroundColor, LightForegroundText, ShowNameOnSquare150x150Logo, Square70x70LogoData, Square150x150LogoData, Square70x70LogoName, Square150x150LogoName, null, null, Square70x70LogoDirectoryPath, Square150x150LogoDirectoryPath);
var Manifest = ManifestService.Decompile(Components);
return Manifest.AppName.Equals("Test") && Manifest.BackgroundColor == BackgroundColor && Manifest.LightForegroundText == LightForegroundText && Manifest.ShowNameOnSquare150x150Logo == ShowNameOnSquare150x150Logo && Manifest.Square70x70LogoData.Equals(Square70x70LogoData) && Manifest.Square150x150LogoData.Equals(Square150x150LogoData) && Manifest.Square70x70LogoName.Equals(Square70x70LogoName) && Manifest.Square150x150LogoName.Equals(Square150x150LogoName) && Manifest.Square70x70LogoFormat.Equals(Square70x70LogoFormat) && Manifest.Square150x150LogoFormat.Equals(Square150x150LogoFormat) && Manifest.Square70x70LogoDirectoryPath.Equals(Square70x70LogoDirectoryPath) && Manifest.Square150x150LogoDirectoryPath.Equals(Square150x150LogoDirectoryPath);
}
public static bool CanBeProcessedTest()
{
var ComponentsTF1 = ManifestService.Compile("Test",(0 << 0) | (0 << 8) | (0 << 16),true,true);
Install(Path.GetTempPath(), ComponentsTF1);
var TF1 = ManifestService.CanBeProcessed(Path.GetTempPath(), "Test");
var ComponentsTF2 = ManifestService.Compile("Test", (0 << 0) | (0 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Jpeg), CreateImage(ImageFormat.Gif), "a", "b", null, null, "_", "");
Install(Path.GetTempPath(), ComponentsTF2);
var TF2 = ManifestService.CanBeProcessed(Path.GetTempPath(), "Test");
var ComponentsTF3 = ManifestService.Compile("Test", (0 << 0) | (0 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Jpeg), CreateImage(ImageFormat.Jpeg), "Test--70x70Logo", "Test--150x150Logo", null, null, "70x70Logo", "a\\b\\c\\d\\e\\f");
Install(Path.GetTempPath(), ComponentsTF3);
var TF3 = ManifestService.CanBeProcessed(Path.GetTempPath(), "Test");
var ComponentsTF4 = ManifestService.Compile("Test", (0 << 0) | (0 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Jpeg), CreateImage(ImageFormat.Gif), "Test--70x70Logo.jpg", "A.gif");
Install(Path.GetTempPath(), ComponentsTF4);
var TF4 = ManifestService.CanBeProcessed(Path.GetTempPath(), "Test");
return TF1 && TF2 && TF3 && TF4;
}
public static bool ManifestInstallerTest()
{
var AppNameTF1 = Path.GetTempFileName();
var AppDirectoryTF1 = Path.GetTempPath();
var ComponentsTF1 = ManifestService.Compile(AppNameTF1, (0 << 0) | (0 << 8) | (0 << 16), true, true);
var TF1 = ManifestInstaller.Install(AppDirectoryTF1, ComponentsTF1, false) && IsInstalled(AppDirectoryTF1, ComponentsTF1);
var AppNameTF2 = Path.GetTempFileName();
var AppDirectoryTF2 = Path.GetTempPath();
var ComponentsTF2 = ManifestService.Compile(AppNameTF2, (0 << 0) | (0 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Jpeg), CreateImage(ImageFormat.Gif), "a", "b", null, null, "_", "");
var TF2 = ManifestInstaller.Install(AppDirectoryTF2, ComponentsTF2, false) && IsInstalled(AppDirectoryTF2, ComponentsTF2);
return TF1 && TF2;
}
public static bool ManifestUninstallerTest()
{
var AppNameTF1 = Path.GetTempFileName();
var AppDirectoryTF1 = Path.GetTempPath();
var ComponentsTF1 = ManifestService.Compile(AppNameTF1, (0 << 0) | (0 << 8) | (0 << 16), true, true);
var TF1 = ManifestUninstaller.Uninstall(AppDirectoryTF1, ComponentsTF1, false) && IsInstalled(AppDirectoryTF1, ComponentsTF1);
var AppNameTF2 = Path.GetTempFileName();
var AppDirectoryTF2 = Path.GetTempPath();
var ComponentsTF2 = ManifestService.Compile(AppNameTF2, (0 << 0) | (0 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Jpeg), CreateImage(ImageFormat.Gif), "a", "b", null, null, "_", "");
var TF2 = ManifestUninstaller.Uninstall(AppDirectoryTF2, ComponentsTF2, false) && IsInstalled(AppDirectoryTF2, ComponentsTF2);
return TF1 == false && TF2 == false;
}
public static bool ManifestDecompilationResultExtensionTest()
{
var TF1 = ManifestService.Decompile(ManifestService.Compile("test", (0 << 0) | (0 << 8) | (0 << 16), true, true)).ContainsImagesData() == false;
var TF2 = ManifestService.Decompile(ManifestService.Compile("test", (0 << 0) | (0 << 8) | (100 << 16), true, true, CreateImage(ImageFormat.Jpeg), CreateImage(ImageFormat.Gif), "a", "b", null, null, "_", "")).ContainsImagesData() == true;
return TF1 && TF2;
}
private static bool IsInstalled(string AppDirectory, ManifestComponents Components)
{
foreach (var Component in Components)
if (File.Exists(Path.Combine(AppDirectory, Component.Value.FileName)) == false)
return false;
return true;
}
private static void Install(string AppDirectory, ManifestComponents Components)
{
foreach (var Component in Components)
{
var TargetInfo = new FileInfo(Path.Combine(AppDirectory, Component.Value.FileName));
Directory.CreateDirectory(TargetInfo.Directory.FullName);
File.WriteAllBytes(TargetInfo.FullName, Component.Value.Data);
}
}
private static byte[] CreateImage(ImageFormat Format)
{
var Stream = new MemoryStream();
SystemIcons.Error.ToBitmap().Save(Stream, Format);
return Stream.ToArray();
}