Exemplo n.º 1
0
        public TypedReference GetNextArg(RuntimeTypeHandle rth)
        {
            if (sigPtr != IntPtr.Zero)
            {
                // This is an ordinary ArgIterator capable of determining
                // types from a signature. Just do a regular GetNextArg.
                return GetNextArg();
            }
            else
            {
                // Prevent abuse of this API with a default ArgIterator (it
                // doesn't require permission to create a zero-inited value
                // type). Check that ArgPtr isn't zero or this API will allow a
                // malicious caller to increment the pointer to an arbitrary
                // location in memory and read the contents.
                if (ArgPtr == IntPtr.Zero)
                    throw new ArgumentNullException();

                TypedReference result = new TypedReference ();
                // reference to TypedReference is banned, so have to pass result as pointer
                unsafe
                {
                    InternalGetNextArg(&result, rth.GetRuntimeType());
                }
                return result;
            }
        }
Exemplo n.º 2
0
    public static int test_0_typedref()
    {
        int i = 5;

        System.TypedReference r = __makeref(i);
        System.Type           t = __reftype(r);

        if (t != typeof(int))
        {
            return(1);
        }
        int j = __refvalue(r, int);

        if (j != 5)
        {
            return(2);
        }

        try {
            object o = __refvalue(r, object);
        } catch (InvalidCastException) {
        }

        return(0);
    }
		public static void SetTypedReference (TypedReference target, object value) 
		{
			if (value == null) {
				throw new ArgumentNullException ("value");
			}
			throw new NotImplementedException ();
		}
 public override unsafe object GetValueDirect(TypedReference obj)
 {
     if (obj.IsNull)
     {
         throw new ArgumentException(Environment.GetResourceString("Arg_TypedReference_Null"));
     }
     return RuntimeFieldHandle.GetValueDirect(this, (RuntimeType) this.FieldType, (void*) &obj, (RuntimeType) this.DeclaringType);
 }
Exemplo n.º 5
0
 public static System.IntPtr AddressOf <T>(this T t)
 {
     unsafe
     {
         System.TypedReference reference = __makeref(t);
         return(*(System.IntPtr *)(&reference));
     }
 }
Exemplo n.º 6
0
 private static String buildLCS( /*int[,,,]*/TypedReference _b,
                         /*char[]*/ TypedReference _X,
                         /*int[]*/ TypedReference _ind)
 {
     int _i = 0;
     for (TypedReference i = __makeref(_i);
         __refvalue(i, int) < RANK; _i++)
         if (__refvalue(_ind, int[])[__refvalue(i, int)] == 0) return "";
Exemplo n.º 7
0
        public static bool Get(ref IStruct @this)
        {
            System.TypedReference tr = __makeref(@this);

            @this = __refvalue(tr, IStruct);

            return(true);
        }
Exemplo n.º 8
0
        public static System.IntPtr AddressOf <T>(T t)
        //refember ReferenceTypes are references to the CLRHeader
        //where TOriginal : struct
        {
            System.TypedReference reference = __makeref(t);

            return(*(System.IntPtr *)(&reference));
        }
Exemplo n.º 9
0
 static System.IntPtr AddressOfRef <T>(ref T t)
 {
     unsafe
     {
         System.TypedReference  reference = __makeref(t);
         System.TypedReference *pRef      = &reference;
         return((System.IntPtr)pRef); //(&pRef)
     }
 }
Exemplo n.º 10
0
        static System.IntPtr AddressOfRef <T>(ref T t)
        //refember ReferenceTypes are references to the CLRHeader
        //where TOriginal : struct
        {
            System.TypedReference reference = __makeref(t);

            System.TypedReference *pRef = &reference;

            return((System.IntPtr)pRef); //(&pRef)
        }
Exemplo n.º 11
0
 private static void TestRef(TypedReference _ref)
 {
     if (__reftype(_ref) == typeof(Array))
     {
         for (int i = 0; i < __refvalue(_ref, Array).Length; i++)
             __refvalue(_ref, Array).SetValue(new Test(), i);
     }
     if (__reftype(_ref) == typeof(long[]))
     {
         for (int i = 0; i < __refvalue(_ref, long[]).Length; i++)
Exemplo n.º 12
0
 public TypedReference GetNextArg()
 {
     TypedReference result = new TypedReference ();
     // reference to TypedReference is banned, so have to pass result as pointer
     unsafe
     {
         FCallGetNextArg (&result);
     }
     return result;
 }
Exemplo n.º 13
0
 public virtual void PackRef(TypedReference _ref, int iterCount)
 {
     if (++iterCount == ITERATIONS)
     {
         UnpackRef(_ref, iterCount);
     }
     else
     {
         ulong N = UnpackRef(_ref, 0);
         PackRef(__makeref(N), iterCount);
     }
 }
Exemplo n.º 14
0
 private static void TestRef(TypedReference _ref)
 {
     if (__reftype(_ref) == typeof(ulong[,]))
     {
         for (int i = 0; i < 2; i++)
         {
             for (int j = 0; j < 3; j++)
             {
                 __refvalue(_ref, ulong[,])[i, j]--;
             }
         }
     }
 }
Exemplo n.º 15
0
 private static void PackRef(TypedReference _ref, int iterCount)
 {
     if (++iterCount == ITERATIONS)
     {
         Console.WriteLine(ITERATIONS.ToString() + " refs packed.");
         UnpackRef(_ref, iterCount);
     }
     else
     {
         ulong N = UnpackRef(_ref, 0);
         PackRef(__makeref(N), iterCount);
     }
 }
Exemplo n.º 16
0
 public unsafe TypedReference GetNextArg(RuntimeTypeHandle rth)
 {
     if (this.sigPtr != IntPtr.Zero)
     {
         return this.GetNextArg();
     }
     if (this.ArgPtr == IntPtr.Zero)
     {
         throw new ArgumentNullException();
     }
     TypedReference reference = new TypedReference();
     this.InternalGetNextArg((void*) &reference, rth);
     return reference;
 }
Exemplo n.º 17
0
        public static TypedReference MakeTypedReference(Object target, FieldInfo[] flds) {
            if (target == null)
                throw new ArgumentNullException("target");
            if (flds == null)
                throw new ArgumentNullException("flds");
            Contract.EndContractBlock();
            if (flds.Length == 0)
                throw new ArgumentException(Environment.GetResourceString("Arg_ArrayZeroError"));

            IntPtr[] fields = new IntPtr[flds.Length];
            // For proper handling of Nullable<T> don't change GetType() to something like 'IsAssignableFrom'
            // Currently we can't make a TypedReference to fields of Nullable<T>, which is fine.  
            RuntimeType targetType = (RuntimeType)target.GetType();
            for (int i = 0; i < flds.Length; i++)
            {
                RuntimeFieldInfo field = flds[i] as RuntimeFieldInfo;
                if (field == null)
                    throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"));

                if (field.IsInitOnly || field.IsStatic)
                    throw new ArgumentException(Environment.GetResourceString("Argument_TypedReferenceInvalidField"));
                
                if (targetType != field.GetDeclaringTypeInternal() && !targetType.IsSubclassOf(field.GetDeclaringTypeInternal()))
                    throw new MissingMemberException(Environment.GetResourceString("MissingMemberTypeRef"));

                RuntimeType fieldType = (RuntimeType)field.FieldType;
                if (fieldType.IsPrimitive)
                    throw new ArgumentException(Environment.GetResourceString("Arg_TypeRefPrimitve"));
                
                if (i < (flds.Length - 1) && !fieldType.IsValueType)
                    throw new MissingMemberException(Environment.GetResourceString("MissingMemberNestErr"));
                
                fields[i] = field.FieldHandle.Value;
                targetType = fieldType;
            }

#if MONO
            return MakeTypedReferenceInternal (target, flds);
#else
            TypedReference result = new TypedReference ();

            // reference to TypedReference is banned, so have to pass result as pointer
            unsafe 
            {
                InternalMakeTypedReference(&result, target, fields, targetType);
            }
            return result;
#endif
        }
Exemplo n.º 18
0
    int InstAddASecondBunchOfInts(int a, __arglist)
    {
        int result = 0;

        System.ArgIterator iter = new System.ArgIterator(__arglist);
        int argCount            = iter.GetRemainingCount();

        for (int i = 0; i < argCount; i++)
        {
            System.TypedReference typedRef = iter.GetNextArg();
            result += (int)TypedReference.ToObject(typedRef);
        }

        return(result);
    }
Exemplo n.º 19
0
    static int AddABunchOfShorts(__arglist)
    {
        int result = 0;

        System.ArgIterator iter = new System.ArgIterator(__arglist);
        int argCount            = iter.GetRemainingCount();

        for (int i = 0; i < argCount; i++)
        {
            System.TypedReference typedRef = iter.GetNextArg();
            result += (short)TypedReference.ToObject(typedRef);
        }

        return(result);
    }
Exemplo n.º 20
0
 public virtual ulong UnpackRef(TypedReference _ref, int iterCount)
 {
     if (iterCount++ == ITERATIONS)
     {
         if (__refvalue(_ref, ulong) == MAGIC)
         {
             throw new ArgumentException();  //cleanup in an unusual way
         }
         else
         {
             throw new Exception();
         }
     }
     else
         return __refvalue(_ref, ulong);
 }
Exemplo n.º 21
0
 public static unsafe TypedReference MakeTypedReference(object target, FieldInfo[] flds)
 {
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     if (flds == null)
     {
         throw new ArgumentNullException("flds");
     }
     if (flds.Length == 0)
     {
         throw new ArgumentException(Environment.GetResourceString("Arg_ArrayZeroError"));
     }
     RuntimeFieldHandle[] handleArray = new RuntimeFieldHandle[flds.Length];
     System.Type type = target.GetType();
     for (int i = 0; i < flds.Length; i++)
     {
         FieldInfo info = flds[i];
         if (!(info is RuntimeFieldInfo))
         {
             throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"));
         }
         if (info.IsInitOnly || info.IsStatic)
         {
             throw new ArgumentException(Environment.GetResourceString("Argument_TypedReferenceInvalidField"));
         }
         if ((type != info.DeclaringType) && !type.IsSubclassOf(info.DeclaringType))
         {
             throw new MissingMemberException(Environment.GetResourceString("MissingMemberTypeRef"));
         }
         System.Type fieldType = info.FieldType;
         if (fieldType.IsPrimitive)
         {
             throw new ArgumentException(Environment.GetResourceString("Arg_TypeRefPrimitve"));
         }
         if ((i < (flds.Length - 1)) && !fieldType.IsValueType)
         {
             throw new MissingMemberException(Environment.GetResourceString("MissingMemberNestErr"));
         }
         handleArray[i] = info.FieldHandle;
         type = fieldType;
     }
     TypedReference reference = new TypedReference();
     InternalMakeTypedReference((void*) &reference, target, handleArray, type.TypeHandle);
     return reference;
 }
Exemplo n.º 22
0
 private static ulong UnpackRef(TypedReference _ref, int iterCount)
 {
     if (iterCount++ == ITERATIONS)
     {
         Console.WriteLine(ITERATIONS.ToString() + " refs unpacked.");
         if (__refvalue(_ref, ulong) == MAGIC)
         {
             Console.WriteLine("Passed.");
             throw new ArgumentException();  //cleanup in an unusual way
         }
         else
         {
             Console.WriteLine("failed.");
             throw new Exception();
         }
     }
     else
         return __refvalue(_ref, ulong);
 }
Exemplo n.º 23
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 public unsafe static Object ToObject(TypedReference value)
 {
     return InternalToObject(&value);
 }
Exemplo n.º 24
0
 public static RuntimeTypeHandle TargetTypeToken (TypedReference value)
 {
     return __reftype(value).TypeHandle;
 }
Exemplo n.º 25
0
 public extern static object ToObject(TypedReference value);
Exemplo n.º 26
0
        public static TypedReference MakeTypedReference(object target, FieldInfo[] flds)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            if (flds == null)
            {
                throw new ArgumentNullException(nameof(flds));
            }
            if (flds.Length == 0)
            {
                throw new ArgumentException(SR.Arg_ArrayZeroError, nameof(flds));
            }

            IntPtr[] fields = new IntPtr[flds.Length];
            // For proper handling of Nullable<T> don't change GetType() to something like 'IsAssignableFrom'
            // Currently we can't make a TypedReference to fields of Nullable<T>, which is fine.
            RuntimeType targetType = (RuntimeType)target.GetType();

            for (int i = 0; i < flds.Length; i++)
            {
                RuntimeFieldInfo?field = flds[i] as RuntimeFieldInfo;
                if (field == null)
                {
                    throw new ArgumentException(SR.Argument_MustBeRuntimeFieldInfo);
                }

                if (field.IsStatic)
                {
                    throw new ArgumentException(SR.Format(SR.Argument_TypedReferenceInvalidField, field.Name));
                }

                if (targetType != field.GetDeclaringTypeInternal() && !targetType.IsSubclassOf(field.GetDeclaringTypeInternal()))
                {
                    throw new MissingMemberException(SR.MissingMemberTypeRef);
                }

                RuntimeType fieldType = (RuntimeType)field.FieldType;
                if (fieldType.IsPrimitive)
                {
                    throw new ArgumentException(SR.Format(SR.Arg_TypeRefPrimitve, field.Name));
                }

                if (i < (flds.Length - 1) && !fieldType.IsValueType)
                {
                    throw new MissingMemberException(SR.MissingMemberNestErr);
                }

                fields[i]  = field.FieldHandle.Value;
                targetType = fieldType;
            }

            TypedReference result = default;

            // reference to TypedReference is banned, so have to pass result as pointer
            unsafe
            {
                InternalMakeTypedReference(&result, target, fields, targetType);
            }
            return(result);
        }
Exemplo n.º 27
0
 static void G(System.TypedReference t)
 {
     __refvalue(t, string) = Orange;
 }
 internal extern void SetValueDirect(RuntimeTypeHandle fieldType, TypedReference obj, Object value, RuntimeTypeHandle contextType);
Exemplo n.º 29
0
 /// <summary>Returns the internal metadata type handle for the specified TypedReference.</summary>
 /// <returns>The internal metadata type handle for the specified TypedReference.</returns>
 /// <param name="value">The TypedReference for which the type handle is requested. </param>
 /// <filterpriority>1</filterpriority>
 public static RuntimeTypeHandle TargetTypeToken(TypedReference value)
 {
     return(new RuntimeTypeHandle(value.klass));
 }
Exemplo n.º 30
0
        private static String Format(TypedReference format, TypedReference _ref)
        {
            int length = __refvalue(format, String).Length;
            char[] chars = __refvalue(format, String).ToCharArray();

            String result = "";
            int arg = 0;
            for (int I = 0; I < length; I++)
            {
                if (chars[I] != '%')
                    result += chars[I];
                else
                {
                    I++;
                    if (I >= length)
                        throw new Exception();

                    bool FALSE = false;
                    bool TRUE = true;
                    TypedReference bLong = __makeref(FALSE);
                    if (chars[I] == 'l')
                    {
                        bLong = __makeref(TRUE);
                        I++;
                        if (I >= length)
                            throw new Exception();
                    }

                    if (arg++ == 1)
                        throw new Exception();

                    switch (chars[I])
                    {
                        case 'b':
                            if (__refvalue(bLong, bool))
                                throw new Exception();
                            if (__reftype(_ref) != typeof(bool))
                                throw new Exception();
                            if (__refvalue(_ref, bool))
                                result += "true";
                            else
                                result += "false";
                            break;

                        case 'd':
                            if (__refvalue(bLong, bool))
                            {
                                if (__reftype(_ref) != typeof(long))
                                    throw new Exception();
                                result += __refvalue(_ref, long).ToString();
                            }
                            else
                            {
                                if (__reftype(_ref) != typeof(int))
                                    throw new Exception();
                                result += __refvalue(_ref, int).ToString();
                            }
                            break;

                        case 'u':
                            if (__refvalue(bLong, bool))
                            {
                                if (__reftype(_ref) != typeof(UInt64))
                                    throw new Exception();
                                result += __refvalue(_ref, ulong).ToString();
                            }
                            else
                            {
                                if (__reftype(_ref) != typeof(uint))
                                    throw new Exception();
                                result += __refvalue(_ref, uint).ToString();
                            }
                            break;

                        case 'f':
                            if (__refvalue(bLong, bool))
                            {
                                if (__reftype(_ref) != typeof(double))
                                    throw new Exception();
                                result += __refvalue(_ref, double).ToString();
                            }
                            else
                            {
                                if (__reftype(_ref) != typeof(float))
                                    throw new Exception();
                                result += __refvalue(_ref, float).ToString();
                            }
                            break;

                        case 's':
                            if (__refvalue(bLong, bool))
                                throw new Exception();
                            if (__reftype(_ref) != typeof(String))
                                throw new Exception();
                            result += __refvalue(_ref, String) != null ? __refvalue(_ref, String) : "(null)";
                            break;

                        case 't':
                            if (__refvalue(bLong, bool))
                                throw new Exception();
                            if (__reftype(_ref) != typeof(DateTime))
                                throw new Exception();
                            result += __refvalue(_ref, DateTime).ToString();
                            break;

                        case 'p':
                            if (__refvalue(bLong, bool))
                                throw new Exception();
                            if (__reftype(_ref) != typeof(PlatformID))
                                throw new Exception();
                            result += __refvalue(_ref, PlatformID).ToString();
                            break;

                        case 'e':
                            if (__refvalue(bLong, bool))
                                throw new Exception();
                            if (__reftype(_ref) != typeof(Mood))
                                throw new Exception();
                            switch (__refvalue(_ref, Mood))
                            {
                                case Mood.good:
                                    result += "good";
                                    break;
                                case Mood.bad:
                                    result += "bad";
                                    break;
                                case Mood.worse:
                                    result += "worse";
                                    break;
                                default:
                                    throw new Exception();
                            }
                            break;

                        default:
                            throw new Exception();
                    }
                }
            }
            return result;
        }
Exemplo n.º 31
0
        public static TypedReference MakeTypedReference(Object target, FieldInfo[] flds)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (flds == null)
            {
                throw new ArgumentNullException("flds");
            }
            if (flds.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Arg_ArrayZeroError"));
            }
            else
            {
                RuntimeFieldHandle[] fields = new RuntimeFieldHandle[flds.Length];
                // For proper handling of Nullable<T> don't change GetType() to something like 'IsAssignableFrom'
                // Currently we can't make a TypedReference to fields of Nullable<T>, which is fine.
                Type targetType = target.GetType();
                for (int i = 0; i < flds.Length; i++)
                {
                    FieldInfo field = flds[i];
                    if (!(field is RuntimeFieldInfo))
                    {
                        throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"));
                    }
                    else if (field.IsInitOnly || field.IsStatic)
                    {
                        throw new ArgumentException(Environment.GetResourceString("Argument_TypedReferenceInvalidField"));
                    }

                    if (targetType != field.DeclaringType && !targetType.IsSubclassOf(field.DeclaringType))
                    {
                        throw new MissingMemberException(Environment.GetResourceString("MissingMemberTypeRef"));
                    }

                    Type fieldType = field.FieldType;
                    if (fieldType.IsPrimitive)
                    {
                        throw new ArgumentException(Environment.GetResourceString("Arg_TypeRefPrimitve"));
                    }

                    if (i < flds.Length - 1)
                    {
                        if (!fieldType.IsValueType)
                        {
                            throw new MissingMemberException(Environment.GetResourceString("MissingMemberNestErr"));
                        }
                    }

                    fields[i]  = field.FieldHandle;
                    targetType = fieldType;
                }
                TypedReference result = new TypedReference();
                // reference to TypedReference is banned, so have to pass result as pointer
                unsafe
                {
                    InternalMakeTypedReference(&result, target, fields, targetType.TypeHandle);
                }
                return(result);
            }
        }
Exemplo n.º 32
0
 public static object ToObject(TypedReference value)
 {
     return(Intrinsics.GetBoxedDataFromPointer(value.pointer));
 }
Exemplo n.º 33
0
 public static unsafe object ToObject(TypedReference value)
 {
     return(InternalToObject(&value));
 }
Exemplo n.º 34
0
 public static void SetTypedReference(TypedReference target, object value)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 35
0
 public static Type GetTargetType(TypedReference value)
 {
     return(__reftype(value));
 }
Exemplo n.º 36
0
 public static RuntimeTypeHandle TargetTypeToken(TypedReference value)
 {
     return(value.type);
 }
Exemplo n.º 37
0
 internal static RuntimeTypeHandle RawTargetTypeToken(TypedReference value)
 {
     return(value._typeHandle);
 }
Exemplo n.º 38
0
 /// <summary>Returns the type of the target of the specified TypedReference.</summary>
 /// <returns>The type of the target of the specified TypedReference.</returns>
 /// <param name="value">The value whose target's type is to be returned. </param>
 /// <filterpriority>1</filterpriority>
 public static Type GetTargetType(TypedReference value)
 {
     throw new NotImplementedException();
 }
 public virtual void SetValueDirect(TypedReference obj, object value)
 {
     throw new NotSupportedException(Environment.GetResourceString("NotSupported_AbstractNonCLS"));
 }
Exemplo n.º 40
0
 public unsafe static void SetTypedReference(TypedReference target, Object value)
 {
     InternalSetTypedReference(&target, value);
 }
 internal extern Object GetValueDirect(RuntimeTypeHandle fieldType, TypedReference obj, RuntimeTypeHandle contextType);
Exemplo n.º 42
0
 public static RuntimeTypeHandle TargetTypeToken(TypedReference value)
 {
     return(__reftype(value).TypeHandle);
 }
Exemplo n.º 43
0
 static void F(System.TypedReference t)
 {
     __refvalue(t, int) = Pass;
 }
Exemplo n.º 44
0
        public void TestExpressionExtensions()
        {
            MyTestClass testClass = new MyTestClass();

            //Todo ... show how to allow to TypedReference use inside the body
            System.TypedReference member = __makeref(testClass.Test);

            System.Type type = typeof(System.Reflection.PropertyInfo);

            System.Reflection.MethodInfo setter = Media.Common.Extensions.ExpressionExtensions.SymbolExtensions.LoadSetter(() => testClass.Test.Equals(null));

            System.Console.WriteLine("setter Name: " + setter.Name);

            System.Console.WriteLine(".Test => " + testClass.Test);

            setter.Invoke(testClass, new[] { "Test" });

            if (false == (string.Compare(testClass.Test, "Test") == 0))
            {
                throw new System.Exception("Did not invoke setter");
            }

            System.Console.WriteLine(".Test => " + testClass.Test);

            testClass = new MyTestClass <int>();

            MyTestClass <int> casted = testClass as MyTestClass <int>;

            System.Console.WriteLine("<int>.Test => " + testClass.Test);

            setter.Invoke(testClass, new[] { "Test" });

            if (false == (string.Compare(testClass.Test, "Test") == 0))
            {
                throw new System.Exception("Did not invoke setter");
            }

            System.Console.WriteLine(".Test => " + testClass.Test);

            System.Console.WriteLine("<int>.Test => " + ((MyTestClass <int>)testClass).Test);

            System.Console.WriteLine("<int>.Property => " + ((MyTestClass <int>)testClass).Property);

            setter = Media.Common.Extensions.ExpressionExtensions.SymbolExtensions.LoadSetter(() => ((MyTestClass <int>)testClass).Property.Equals(null));

            System.Console.WriteLine("setter Name: " + setter.Name);

            setter.Invoke(testClass, new object[] { 1 });

            if (false == (casted.Property == 1))
            {
                throw new System.Exception("Did not invoke setter");
            }

            System.Console.WriteLine("<int>.Property => " + ((MyTestClass <int>)testClass).Property);

            System.Console.WriteLine("<int>.Property => " + casted.Property);

            setter = Media.Common.Extensions.ExpressionExtensions.SymbolExtensions.LoadSetter(() => casted.AnotherProperty.Equals(null));

            System.Console.WriteLine("<int>.AnotherProperty => " + ((MyTestClass <int>)testClass).AnotherProperty);

            System.Console.WriteLine("<int>.AnotherProperty => " + casted.AnotherProperty);

            setter.Invoke(testClass, new object[] { 2 });

            if (false == (casted.AnotherProperty == 2))
            {
                throw new System.Exception("Did not invoke setter");
            }

            System.Console.WriteLine("<int>.AnotherProperty => " + ((MyTestClass <int>)testClass).AnotherProperty);

            System.Console.WriteLine("<int>.AnotherProperty => " + casted.AnotherProperty);

            System.Reflection.TypeInfo typeInfo = Media.Common.Extensions.ExpressionExtensions.SymbolExtensions.GetTypeInfo(() => new MyTestClass <int>());

            if (typeInfo.GetGenericArguments()[0] != typeof(int))
            {
                throw new System.Exception("Not correct type");
            }

            System.Console.WriteLine("TypeInfo.Name " + typeInfo.Name);

            System.Console.WriteLine("TypeInfo.MetadataToken " + typeInfo.MetadataToken);

            if (typeInfo.GetGenericArguments()[0] != typeof(int))
            {
                throw new System.Exception("Not correct type");
            }

            typeInfo = Media.Common.Extensions.ExpressionExtensions.SymbolExtensions.GetTypeInfo(() => (typeof(MyTestClass <int>)).GetType());

            if (typeInfo.GetGenericArguments()[0] != typeof(int))
            {
                throw new System.Exception("Not correct type");
            }

            System.Type unboundedType = typeof(MyTestClass <>);

            typeInfo = Media.Common.Extensions.ExpressionExtensions.SymbolExtensions.GetTypeInfo(() => (unboundedType).GetType());

            System.Console.WriteLine("TypeInfo.Name " + typeInfo.Name);

            System.Console.WriteLine("TypeInfo.MetadataToken " + typeInfo.MetadataToken);

            System.Reflection.MethodInfo methodInfo = Media.Common.Extensions.ExpressionExtensions.SymbolExtensions.GetMethodInfo(() => ((MyTestClass <int>)null).Method());

            if (false.Equals(methodInfo.DeclaringType.Equals(typeof(MyTestClass <int>))))
            {
                throw new System.Exception("Not correct type");
            }

            System.Console.WriteLine("GetMethodInfo.Name " + methodInfo.Name);

            System.Console.WriteLine("GetMethodInfo.MetadataToken " + methodInfo.MetadataToken);
        }
Exemplo n.º 45
0
        public unsafe static void SetTypedReference(TypedReference target, Object value)
        {
#if MONO
            throw new NotImplementedException ("SetTypedReference");
#else
            InternalSetTypedReference(&target, value);
#endif
        }
 public static Type GetTargetType(TypedReference value)
 {
     return(default(Type));
 }
Exemplo n.º 47
0
 public static Type GetTargetType(TypedReference value)
 {
     return(Type.GetTypeFromHandle(value.type));
 }
Exemplo n.º 48
0
 public override void SetValueDirect(TypedReference obj, Object value)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 49
0
 public static Type GetTargetType (TypedReference value)
 {
     return __reftype(value);
 }
Exemplo n.º 50
0
 private extern static void InternalObjectToTypedReference(TypedReference byrefValue, Object value, RuntimeTypeHandle typeHandle);
Exemplo n.º 51
0
 public unsafe static void SetTypedReference(TypedReference target, Object value)
 {
     InternalSetTypedReference(&target, value);
 }
Exemplo n.º 52
0
        public override Object GetValueDirect(TypedReference obj)
        {
            if (obj.IsNull)
                throw new ArgumentException(Environment.GetResourceString("Arg_TypedReference_Null"));
            Contract.EndContractBlock();

            unsafe
            {
                // Passing TypedReference by reference is easier to make correct in native code
                return RuntimeFieldHandle.GetValueDirect(this, (RuntimeType)FieldType, &obj, (RuntimeType)DeclaringType);
            }
        }
Exemplo n.º 53
0
 public unsafe void SetValue(object pValue, int pIndex)
 {
     TypedReference reference = new TypedReference();
     InternalGetValueReference(&reference, 1, &pIndex);
     InternalSetValueReference(&reference, pValue);
 }
Exemplo n.º 54
0
 public static void SetTypedReference(TypedReference target, object?value)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 55
0
 public override Object GetValueDirect(TypedReference obj)
 {
     throw new NotImplementedException();
 }    
Exemplo n.º 56
0
 public override Object GetValueDirect(TypedReference obj)
 {
     return GetValue(null);
 }
 public static object ToObject(TypedReference arg0)
 {
     return(default(object));
 }
Exemplo n.º 58
0
 public override void SetValueDirect(TypedReference obj,Object value)
 {
     throw new FieldAccessException(Environment.GetResourceString("Acc_ReadOnly"));
 }
Exemplo n.º 59
0
 private static void Test(String format, TypedReference arg, String result)
 {
     String s = Format(__makeref(format), arg);
     if (s != result)
     {
         throw new Exception();
     }
 }
Exemplo n.º 60
0
 public static Type GetTargetType(TypedReference value) => Type.GetTypeFromHandle(value._typeHandle);