Ejemplo n.º 1
0
        public static void UnboxTypedRef(object box, TypedRefPtr typedRef)
        {
            TypedReferenceHelpers.UnboxTypedRef(box, typedRef, box.GetType());
            bool flag = box is IValueTypeBox;

            if (flag)
            {
                TypedReferenceHelpers.CastTypedRef(typedRef, ((IValueTypeBox)box).GetValueType());
            }
        }
Ejemplo n.º 2
0
        public static void UnboxTypedRef(object box, TypedRefPtr typedRef, Type boxType)
        {
            object obj  = TypedReferenceHelpers.unboxHelpers[boxType];
            bool   flag = obj == null;

            if (flag)
            {
                Hashtable obj2 = TypedReferenceHelpers.unboxHelpers;
                lock (obj2) {
                    obj = TypedReferenceHelpers.unboxHelpers[boxType];
                    bool flag2 = obj == null;
                    if (flag2)
                    {
                        obj = TypedReferenceHelpers.BuildUnboxHelper(boxType);
                        TypedReferenceHelpers.unboxHelpers[boxType] = obj;
                    }
                }
            }
            ((TypedReferenceHelpers.Unbox)obj)(box, typedRef);
        }
Ejemplo n.º 3
0
        public unsafe static void MakeTypedRef(void *ptr, TypedRefPtr typedRef, Type targetType)
        {
            object obj  = TypedReferenceHelpers.makeHelpers[targetType];
            bool   flag = obj == null;

            if (flag)
            {
                Hashtable obj2 = TypedReferenceHelpers.makeHelpers;
                lock (obj2) {
                    obj = TypedReferenceHelpers.makeHelpers[targetType];
                    bool flag2 = obj == null;
                    if (flag2)
                    {
                        obj = TypedReferenceHelpers.BuildMakeHelper(targetType);
                        TypedReferenceHelpers.makeHelpers[targetType] = obj;
                    }
                }
            }
            ((TypedReferenceHelpers.Make)obj)(ptr, typedRef);
        }
Ejemplo n.º 4
0
        public unsafe static void SetTypedRef(object value, TypedRefPtr typedRef)
        {
            Type   targetType = TypedReference.GetTargetType(*(TypedReference *)typedRef);
            object obj        = TypedReferenceHelpers.setHelpers[targetType];
            bool   flag       = obj == null;

            if (flag)
            {
                Hashtable obj2 = TypedReferenceHelpers.setHelpers;
                lock (obj2) {
                    obj = TypedReferenceHelpers.setHelpers[targetType];
                    bool flag2 = obj == null;
                    if (flag2)
                    {
                        obj = TypedReferenceHelpers.BuildSetHelper(targetType);
                        TypedReferenceHelpers.setHelpers[targetType] = obj;
                    }
                }
            }
            ((TypedReferenceHelpers.Set)obj)(value, typedRef);
        }
Ejemplo n.º 5
0
        public unsafe static void GetFieldAddr(EmuContext context, object obj, FieldInfo field, TypedRefPtr typedRef)
        {
            object obj2 = TypedReferenceHelpers.fieldAddrHelpers[field];
            bool   flag = obj2 == null;

            if (flag)
            {
                Hashtable obj3 = TypedReferenceHelpers.fieldAddrHelpers;
                lock (obj3) {
                    obj2 = TypedReferenceHelpers.fieldAddrHelpers[field];
                    bool flag2 = obj2 == null;
                    if (flag2)
                    {
                        obj2 = TypedReferenceHelpers.BuildAddrHelper(field);
                        TypedReferenceHelpers.fieldAddrHelpers[field] = obj2;
                    }
                }
            }
            bool           flag3 = obj == null;
            TypedReference typedReference;

            if (flag3)
            {
                typedReference = default(TypedReference);
            }
            else
            {
                bool flag4 = obj is IReference;
                if (flag4)
                {
                    ((IReference)obj).ToTypedReference(context, (void *)(&typedReference), field.DeclaringType);
                }
                else
                {
                    typedReference = __makeref(obj);
                    TypedReferenceHelpers.CastTypedRef((void *)(&typedReference), obj.GetType());
                }
            }
            ((TypedReferenceHelpers.FieldAdr)obj2)((void *)(&typedReference), typedRef);
        } // Token: 0x0600019C RID: 412 RVA: 0x0000AD9C File Offset: 0x00008F9C
Ejemplo n.º 6
0
        public unsafe static void CastTypedRef(TypedRefPtr typedRef, Type targetType)
        {
            Type targetType2 = TypedReference.GetTargetType(*(TypedReference *)typedRef);
            KeyValuePair <Type, Type> keyValuePair = new KeyValuePair <Type, Type>(targetType2, targetType);
            object obj  = TypedReferenceHelpers.castHelpers[keyValuePair];
            bool   flag = obj == null;

            if (flag)
            {
                Hashtable obj2 = TypedReferenceHelpers.castHelpers;
                lock (obj2) {
                    obj = TypedReferenceHelpers.castHelpers[keyValuePair];
                    bool flag2 = obj == null;
                    if (flag2)
                    {
                        obj = TypedReferenceHelpers.BuildCastHelper(targetType2, targetType);
                        TypedReferenceHelpers.castHelpers[keyValuePair] = obj;
                    }
                }
            }
            ((TypedReferenceHelpers.Cast)obj)(typedRef);
        }