示例#1
0
        //
        // C# port of GCHandleValidatePinnedObject(OBJECTREF) in MarshalNative.cpp.
        //
        private static void GCHandleValidatePinnedObject(Object obj)
        {
            if (obj == null)
            {
                return;
            }
            if (obj is String)
            {
                return;
            }
            EETypePtr eeType = obj.EETypePtr;

            if (eeType.IsArray)
            {
                EETypePtr elementEEType = eeType.ArrayElementType;
                if (elementEEType.IsPrimitive)
                {
                    return;
                }
                if (elementEEType.IsValueType && elementEEType.MightBeBlittable())
                {
                    return;
                }
            }
            else if (eeType.MightBeBlittable())
            {
                return;
            }
            throw new ArgumentException(SR.Argument_NotIsomorphic);
        }