Beispiel #1
0
        static void Main(string[] args)
        {
            string lib = Path.Combine(
                new FileInfo(new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath).Directory.FullName,
                "lib.dll");

            using (var platform = new ShadowPlatformLibrary(lib))
            {
                var maybeParse = platform.GetFunc <MaybeParse, RustOptionInt32>("maybe_parse");

                var number = maybeParse.Invoke(fn => fn("123")).ToOption().UnwrapOr(-1);
                Console.WriteLine(number);
                number = maybeParse.Invoke(fn => fn("abc")).ToOption().UnwrapOr(-1);

                Console.WriteLine(number);

                var maybePos = platform.GetFunc <MaybePos, RustOptionVector3>("maybe_pos");

                var vec = maybePos.Invoke(fn => fn()).ToOption().Unwrap();
                Console.WriteLine(vec);

                var magnitude = platform.GetFunc <Magnitude, float>("magnitude");
                Console.WriteLine(magnitude.Invoke(fn => fn(vec)));
            }
        }
Beispiel #2
0
 public ShadowPlatformAction(ShadowPlatformLibrary shadow, string name)
 {
     _action          = shadow.LoadFunc <T, TResult>(name);
     shadow.Reloaded += delegate
     {
         _action = shadow.LoadFunc <T, TResult>(name);
     };
 }