Ejemplo n.º 1
0
        static void UseWinRtComponent_Factory()
        {
            var myClass  = new WinRtComponent.NativeClass("Greetings to %s from factory!");
            var greeting = myClass.GreetUser("Ninja Cat");

            Console.WriteLine(greeting);
        }
Ejemplo n.º 2
0
        //[MethodImpl(MethodImplOptions.NoInlining)]
        //static void RegisterWinRtTypes(ManagedHooksManager.HooksManager hooksManager)
        //{
        //    hooksManager.RegisterWinRtType<WinRtComponent.NativeClass>();
        //}

        static void UseWinRtComponent_DefaultCtor()
        {
            var myClass  = new WinRtComponent.NativeClass();
            var greeting = myClass.GreetUser("Ninja Cat");

            Console.WriteLine(greeting);
        }
Ejemplo n.º 3
0
        static void UseWinRtComponent_StaticMethod()
        {
            var myClass = new WinRtComponent.NativeClass();

            WinRtComponent.NativeClass.SetGreeting(myClass, "Cheers to %s from statics!");
            var greeting = myClass.GreetUser("Ninja Cat");

            Console.WriteLine(greeting);
        }
Ejemplo n.º 4
0
        static void UseWinRtComponent_Throwing()
        {
            var myClass = new WinRtComponent.NativeClass();

            try
            {
                myClass.GreetUser(string.Empty); // throws ArgumentException
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex);
                Console.WriteLine("Greeting format was: " + myClass.Greeting);
            }
        }