Ejemplo n.º 1
0
        public void Replace()
        {
            var src  = new ArgumentCollection(new string[0], '/', true);
            var dest = new Installer(Format.Json, GetExamplesWith("SampleSkeleton.json"));

            var s0 = dest.Config.Ports[0].Proxy;
            var c0 = src.ReplaceDirectory(s0);

            Assert.That(s0, Is.EqualTo(@"%%dir%%\CubePDF\CubeProxy.exe"));
            Assert.That(c0, Is.Not.EqualTo(s0));
            Assert.That(c0, Does.Not.StartWith("%%dir%%"));
            Assert.That(c0, Does.EndWith("CubeProxy.exe"));

            var s1 = dest.Config.Ports[0].Application;
            var c1 = src.ReplaceDirectory(s1);

            Assert.That(s1, Is.EqualTo(@"%%DIR%%\CubePDF\cubepdf.exe"));
            Assert.That(c1, Is.Not.EqualTo(s1));
            Assert.That(c1, Does.Not.StartsWith("%%DIR%%"));
            Assert.That(c1, Does.EndWith("cubepdf.exe"));

            var s2 = dest.Config.Ports[1].Proxy;
            var c2 = src.ReplaceDirectory(s2);

            Assert.That(s2, Is.EqualTo(@"C:\Program Files\CubePDF\CubeProxy.exe"));
            Assert.That(c2, Is.EqualTo(s2));

            var s3 = dest.Config.Ports[1].Arguments;
            var c3 = src.ReplaceDirectory(s3);

            Assert.That(s3, Is.Empty);
            Assert.That(c3, Is.EqualTo(s3));
        }
Ejemplo n.º 2
0
        /* ----------------------------------------------------------------- */
        ///
        /// ReplaceDirectory
        ///
        /// <summary>
        /// Replaces some directory path.
        /// </summary>
        ///
        /// <param name="src">Source arguments.</param>
        /// <param name="dest">Target configuration.</param>
        ///
        /* ----------------------------------------------------------------- */
        public static void ReplaceDirectory(this ArgumentCollection src, DeviceConfig dest)
        {
            var ca = Environment.SpecialFolder.CommonApplicationData.GetName();

            foreach (var e in dest.Ports)
            {
                e.Temp        = System.IO.Path.Combine(ca, e.Temp);
                e.Proxy       = src.ReplaceDirectory(e.Proxy);
                e.Application = src.ReplaceDirectory(e.Application);
                e.Arguments   = src.ReplaceDirectory(e.Arguments);
            }
        }
Ejemplo n.º 3
0
        /* ----------------------------------------------------------------- */
        ///
        /// CreateInstaller
        ///
        /// <summary>
        /// Creates a new instance of the Installer class with the
        /// specified arguments.
        /// </summary>
        ///
        /// <param name="src">Source arguments.</param>
        ///
        /// <returns>Installer object.</returns>
        ///
        /* ----------------------------------------------------------------- */
        public static Installer CreateInstaller(this ArgumentCollection src)
        {
            var dest = new Installer(Format.Json, src.GetConfiguration())
            {
                Recursive         = src.HasForceOption(),
                ResourceDirectory = src.GetResourceDirectory(),
            };

            src.ReplaceDirectory(dest.Config);
            return(dest);
        }