示例#1
0
 public void PreScriptLoad(KCModHelper helper)
 {
     if (!InteropClient.TryGetMod("SimpleDemo2", out modAssembly))
     {
         return;
     }
     helper.Log("Successfully loaded SimpleDemo2");
 }
示例#2
0
        public void PreScriptLoad(KCModHelper helper)
        {
            if (!InteropClient.TryGetMod("PatchMethods2", out modAssembly))
            {
                return;
            }
            HarmonyInstance instance = HarmonyInstance.Create("PatchMethods2");

            instance.Patch(modAssembly.GetType("Examples.PatchMethods.PatchMethods2.PatchMethods2").GetMethod("SceneLoaded"), prefix: new HarmonyMethod(typeof(PatchMethods1).GetMethod("PatchPrefix", Harmony.AccessTools.all)));
        }
示例#3
0
    public static void Main(string[] args)
    {
        Console.WriteLine("Application started.");

        var runtimeVersion = typeof(object).Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "Unknown";

        Console.WriteLine($"NetCoreAppVersion: {runtimeVersion}");

        InteropClient.Run(args);
    }
示例#4
0
        public void PreScriptLoad(KCModHelper helper)
        {
            if (!InteropClient.TryGetMod("AccessFields2", out modAssembly))
            {
                return;
            }
            Type      fieldClass = modAssembly.GetType("Examples.AccessFields.AccessFields2.AccessFields2");
            FieldInfo field      = fieldClass.GetField("myString", Harmony.AccessTools.all);

            helper.Log((string)field.GetValue(null));
        }
示例#5
0
        public void PreScriptLoad(KCModHelper helper)
        {
            if (!InteropClient.TryGetMod("CallMethods2", out modAssembly))
            {
                return;
            }
            Type       type   = modAssembly.GetType("Examples.CallMethods.CallMethods2.CallMethods2");
            MethodInfo method = type.GetMethod("AddSeventyThree", Harmony.AccessTools.all);

            helper.Log(((int)method.Invoke(null, new object[] { 56 })).ToString());
            Func <int, int> delegateMethod = (Func <int, int>)Delegate.CreateDelegate(typeof(Func <int, int>), method);

            helper.Log(delegateMethod(56).ToString());
        }
示例#6
0
        public void PreScriptLoad(KCModHelper helper)
        {
            if (!InteropClient.TryGetMod("UseClasses2", out modAssembly))
            {
                return;
            }
            Type       classType  = modAssembly.GetType("Examples.UseClasses.UseClasses2.DemoClass");
            MethodInfo logMessage = classType.GetMethod("LogMessage", Harmony.AccessTools.all);
            object     instance   = Activator.CreateInstance(classType);

            logMessage.Invoke(instance, new object[] { helper });
            instance = Activator.CreateInstance(classType, new object[] { "Goodbye!" });
            logMessage.Invoke(instance, new object[] { helper });
        }
示例#7
0
    public static void Run(string[] args)
    {
        var parserResult = Parser.Default.ParseArguments <ClientOptions>(args)
                           .WithNotParsed(errors => Environment.Exit(1))
                           .WithParsed(options =>
        {
            Console.WriteLine("Use TLS: " + options.UseTls);
            Console.WriteLine("Use Test CA: " + options.UseTestCa);
            Console.WriteLine("Client type: " + options.ClientType);
            Console.WriteLine("Server host: " + options.ServerHost);
            Console.WriteLine("Server port: " + options.ServerPort);

            using (var interopClient = new InteropClient(options))
            {
                interopClient.Run().GetAwaiter().GetResult();
            }
        });
    }
示例#8
0
        public async Task <string> RunTestAsync(string serverHost, int serverPort, string grpcWebMode, string testCase)
        {
            var clientOptions = new ClientOptions
            {
                TestCase    = testCase,
                ServerHost  = serverHost,
                ServerPort  = serverPort,
                UseTls      = false,
                GrpcWebMode = grpcWebMode
            };
            var client = new InteropClient(clientOptions, _loggerFactory);

            try
            {
                await client.Run();
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                return(ex.ToString());
            }

            return("Success");
        }
示例#9
0
 public void Preload(KCModHelper helper)
 {
     InteropClient.Register("PatchMethods1");
 }
示例#10
0
 public static void Main(string[] args)
 {
     InteropClient.Run(args);
 }
示例#11
0
 public void Preload(KCModHelper helper)
 {
     InteropClient.Register("AccessFields1");
 }
示例#12
0
 public void Preload(KCModHelper helper)
 {
     InteropClient.Register("CallMethods2");
 }
示例#13
0
 public void Preload(KCModHelper helper)
 {
     InteropClient.Register("SimpleDemo2");
 }
示例#14
0
 public void Preload(KCModHelper helper)
 {
     InteropClient.Register("PatchMethods2");
     name = "Elon Musk";
 }
示例#15
0
 public void Preload(KCModHelper helper)
 {
     InteropClient.Register("UseClasses2");
 }