예제 #1
0
파일: Program.cs 프로젝트: yumiris/HCE
        public static void Main(string[] args)
        {
            var config = new LoaderConfiguration();
            var loader = new Loader(config);

            try
            {
                if (args.Length == 0)
                {
                    loader.Start(ExecutableFactory.Detect());
                    return;
                }

                /**
                 * The parameters are expected to be the HCE ones, e.g. `-window`, `-safemode`, etc.
                 * This effectively makes the SPV3 Loader a wrapper around the HCE executable.
                 */
                var parameters = new ParametersParser().Parse(string.Join(" ", args));

                /**
                 * This allows explicit declaration of the path which the HCE executable resides in.
                 * If the path isn't declared, then we implicitly attempt to detect the executable.
                 */
                var executable = args[0].Contains(Executable.Name)
                    ? new Executable(args[0])
                    : ExecutableFactory.Detect();

                loader.Start(executable, parameters);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #2
0
 public WorkplanExecutable GetMainWorkplan()
 {
     if (rootWorkplan == null)
     {
         rootWorkplan = (WorkplanExecutable)ExecutableFactory.fromId(finder, finder.GetMainWorkplan());
     }
     return(rootWorkplan);
 }
        public void Exists_WhenNotExists_ReturnsFalse()
        {
            var factory = new ExecutableFactory(
                new[] { new BasicParameterValueFactory() },
                new[] { typeof(CreateFoo) });

            var result = factory.Exists("CreateBar");

            result.Should().BeFalse();
        }
        public void Create_WhenExecutableTypeNameIsNotInRegisteredAssemblies_Throws()
        {
            var factory = new ExecutableFactory(
                new[] { new BasicParameterValueFactory() },
                new[] { typeof(CreateFoo) });

            var exception = Assert.Throws <TypeNotFoundException>(() => factory.Create(new ExecutableInfo(
                                                                                           "CreateFooBar", Enumerable.Empty <ExecutableParameterInfo>())));

            exception.TypeShortName.Should().Be("CreateFooBar");
        }
        public void Create_WhenNoParameterFactoryQualifiesForCommandConstructorParameterType_Throws()
        {
            var factory = new ExecutableFactory(
                Enumerable.Empty <IParameterValueFactory>(),
                new[] { typeof(CreateFoo) });

            var exception = Assert.Throws <NoQualifyingParameterValueFactoryException>(() => factory.Create(new ExecutableInfo("CreateFoo",
                                                                                                                               new [] { new ExecutableParameterInfo("id", "1") })));

            exception.TypeShortName.Should().Be("Int32");
        }
        public void Create_WhenMissingParameterThatHasDefaultValue_CreatesCommandWithDefaultValue()
        {
            var factory = new ExecutableFactory(
                new[] { new BasicParameterValueFactory() },
                new[] { typeof(CreateFoo) });

            var result = factory.Create(typeof(CreateFoo));

            result.Should().NotBeNull();
            result.Should().BeOfType <CreateFoo>();
            result.As <CreateFoo>().Bar.Should().Be("bar");
        }
예제 #7
0
파일: Program.cs 프로젝트: yumiris/HCE
 private static void HandleDetectCommand()
 {
     try
     {
         Console.WriteLine(ExecutableFactory.Get(ExecutableFactory.Type.Detect).Path);
         Environment.Exit(0);
     }
     catch (FileNotFoundException e)
     {
         ErrorExit(e.Message, 4);
         Console.Error.WriteLine(e.Message);
     }
 }
예제 #8
0
파일: Loader.cs 프로젝트: yumiris/HCE
        private void Detect()
        {
            Info("Invoked the Loader.Detect command.");
            Info("Attempting to detect executable path.");

            try
            {
                Console.WriteLine(ExecutableFactory.Get(ExecutableFactory.Type.Detect, Output).Path);
            }
            catch (FileNotFoundException e)
            {
                Fail(e.Message, ExitType.Exception);
            }
        }
        public void Create_WhenExecutableTypeConstructorDoesNotMatchPassedParameters_Throws()
        {
            var factory = new ExecutableFactory(
                new[] { new BasicParameterValueFactory() },
                new[] { typeof(CreateFoo) });

            var parameters = new List <ExecutableParameterInfo>
            {
                new ExecutableParameterInfo("id", "1"),
                new ExecutableParameterInfo("dateCreated", DateTime.Now.ToString(CultureInfo.InvariantCulture)),
                new ExecutableParameterInfo("foo", "bar")
            };

            var exception = Assert.Throws <ConstructorNotFoundException>(() =>
                                                                         factory.Create(new ExecutableInfo("CreateFoo", parameters)));

            exception.Type.Should().Be(typeof(CreateFoo));
            exception.Parameters.Should().BeEquivalentTo(parameters.Select(p => p.Name).ToList());
        }
        public void Create_WhenCommandAssemblyIsRegistered_CreatesCommand()
        {
            var factory = new ExecutableFactory(
                new IParameterValueFactory[] { new BasicParameterValueFactory(), new DateTimeParameterValueFactory(CultureInfo.InvariantCulture) },
                new [] { typeof(CreateFoo) });

            var created = new DateTime(2017, 1, 1, 14, 0, 0);
            var result  = factory.Create(
                typeof(CreateFoo),
                new ExecutableParameterInfo("bar", "something"),
                new ExecutableParameterInfo("id", "12345"),
                new ExecutableParameterInfo("datecreated", created.ToString(CultureInfo.InvariantCulture)));

            result.Should().NotBeNull();
            result.Should().BeOfType <CreateFoo>();
            result.As <CreateFoo>().Id.Should().Be(12345);
            result.As <CreateFoo>().Bar.Should().Be("something");
            result.As <CreateFoo>().DateCreated.Should().Be(created);
        }
예제 #11
0
        public static void Main(string[] args)
        {
            var config = new LoaderConfiguration();
            var loader = new Loader(config, new StatusOutput());

            try
            {
                Task.Run(() =>
                {
                    /**
                     * Implicitly detect the HCE executable and start it without any parameters.
                     */
                    if (args.Length == 0)
                    {
                        loader.Start(ExecutableFactory.Detect());
                        return;
                    }

                    /**
                     * The parameters are expected to be the HCE ones, e.g. `-window`, `-safemode`, etc.
                     * This effectively makes the SPV3 Loader a wrapper around the HCE executable.
                     */
                    var parameters = new ParametersParser().Parse(string.Join(" ", args));

                    /**
                     * This allows explicit declaration of the path which the HCE executable resides in.
                     * If the path isn't declared, then we implicitly attempt to detect the executable.
                     */
                    var executable = args[0].Contains(Executable.Name)
                        ? new Executable(args[0])
                        : ExecutableFactory.Detect();

                    loader.Start(executable, parameters);
                }).GetAwaiter().GetResult();
            }
            catch (SecurityException e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
예제 #12
0
파일: Program.cs 프로젝트: yumiris/HCE
        private static void HandleLoadCommand(string[] args)
        {
            var executable = new Atarashii.Executable(Atarashii.Executable.Name);

            if (args.Length > 1)
            {
                executable = new Atarashii.Executable(args[1]);
            }
            else
            {
                try
                {
                    executable = ExecutableFactory.Get(ExecutableFactory.Type.Detect);
                }
                catch (FileNotFoundException e)
                {
                    ErrorExit(e.Message, 1);
                }
            }

            try
            {
                executable.Load();
            }
            catch (LoaderException e)
            {
                ErrorExit(e.Message, 2);
            }
            catch (Exception e)
            {
                ErrorExit(e.Message, 3);
            }

            Console.WriteLine($"The specified executable '{executable.Path}' has been loaded.");
            Environment.Exit(0);
        }
예제 #13
0
파일: Loader.cs 프로젝트: yumiris/HCE
 /// <summary>
 ///     Attempts to detect the path of the HCE executable on the file system.
 /// </summary>
 /// <returns>
 ///     Path to the HCE executable, assuming its installation is legal.
 /// </returns>
 public static string Detect()
 {
     return(ExecutableFactory.Get(ExecutableFactory.Type.Detect).Path);
 }
예제 #14
0
 public ExecutableFactoryTest()
 {
     this.testee = new ExecutableFactory<IExtension>();
 }
예제 #15
0
 public void Setup()
 {
     _factory = new ExecutableFactory();
 }
예제 #16
0
 public Executable GetSpecificWorkplan(long wpid)
 {
     return(ExecutableFactory.fromId(finder, wpid));
 }