예제 #1
0
파일: N565.cs 프로젝트: ste10k1/Bridge
        public static void TestUseCase(Assert assert)
        {
            assert.Expect(7);

            var t1 = new Type();

            assert.Ok(t1 != null, "#565 t1");

            var t2 = new ValueType();

            assert.Ok(t2 != null, "#565 t2");

            var t3 = new IntPtr();

            assert.Ok(t3.GetType() == typeof(IntPtr), "#565 t3");

            var t4 = new UIntPtr();

            assert.Ok(t4.GetType() == typeof(UIntPtr), "#565 t4");

            var t5 = new ParamArrayAttribute();

            assert.Ok(t5 != null, "#565 t5");

            var t6 = new RuntimeTypeHandle();

            assert.Ok(t6.GetType() == typeof(RuntimeTypeHandle), "#565 t6");

            var t7 = new RuntimeFieldHandle();

            assert.Ok(t7.GetType() == typeof(RuntimeFieldHandle), "#565 t7");
        }
예제 #2
0
        public SyncEntityFactory GetEntityFactory(RuntimeTypeHandle typeHandle)
        {
            if (EntityFactoriesByType.TryGetValue(typeHandle, out SyncEntityFactory descriptor))
            {
                return(descriptor);
            }

            throw new NetcodeUnexpectedEntityException(string.Format(
                                                           "No definitions are found for type {0}. Have you enumerated this type as a SyncEntity?",
                                                           typeHandle.GetType().FullName
                                                           ));
        }
예제 #3
0
        // TODO: Improve for real usage
        public static void RunClassConstructor(RuntimeTypeHandle type)
        {
            const BindingFlags flags =
                BindingFlags.Instance |
                BindingFlags.Public |
                BindingFlags.NonPublic;

            var ctType = type.GetType();
            var ctor   = ctType.GetConstructor(flags, null, new Type[0], null);

            ctType = null;

            ctor.Invoke(new object[0]);
            ctor = null;
        }
    public static void Main()
    {
        MyClass1 myClass1 = new MyClass1();

        // Get the RuntimeTypeHandle from an object.
        RuntimeTypeHandle myRTHFromObject = Type.GetTypeHandle(myClass1);
        // Get the RuntimeTypeHandle from a type.
        RuntimeTypeHandle myRTHFromType = typeof(MyClass1).TypeHandle;

        Console.WriteLine("\nmyRTHFromObject.Value:  {0}", myRTHFromObject.Value);
        Console.WriteLine("myRTHFromObject.GetType():  {0}", myRTHFromObject.GetType());
        Console.WriteLine("Get the type back from the handle...");
        Console.WriteLine("Type.GetTypeFromHandle(myRTHFromObject):  {0}",
                          Type.GetTypeFromHandle(myRTHFromObject));

        Console.WriteLine("\nmyRTHFromObject.Equals(myRTHFromType):  {0}",
                          myRTHFromObject.Equals(myRTHFromType));

        Console.WriteLine("\nmyRTHFromType.Value:  {0}", myRTHFromType.Value);
        Console.WriteLine("myRTHFromType.GetType():  {0}", myRTHFromType.GetType());
        Console.WriteLine("Get the type back from the handle...");
        Console.WriteLine("Type.GetTypeFromHandle(myRTHFromType):  {0}",
                          Type.GetTypeFromHandle(myRTHFromType));
    }