예제 #1
0
파일: McgModule.cs 프로젝트: tmds/corert
        /// <summary>
        /// Finds McgStructMarshalData for a struct if it is defined in this module
        /// </summary>
        /// <param name="structTypeHandle">TypeHandle for the safe struct</param>
        /// <param name="structMarshalData">McgStructMarshalData for the struct</param>
        /// <returns>True if the struct marshal data is available in this module</returns>
        internal bool TryGetStructMarshalData(RuntimeTypeHandle structTypeHandle, out McgStructMarshalData structMarshalData)
        {
            structMarshalData = default(McgStructMarshalData);

            if (m_structMarshalData == null)
            {
                return(false);
            }

            for (int i = 0; i < m_structMarshalData.Length; i++)
            {
                if (structTypeHandle.Equals(m_structMarshalData[i].SafeStructType))
                {
                    if (m_structMarshalData[i].HasInvalidLayout)
                    {
                        throw new ArgumentException(SR.Format(SR.Argument_MustHaveLayoutOrBeBlittable, structTypeHandle.GetDisplayName()));
                    }

                    structMarshalData = m_structMarshalData[i];

                    return(true);
                }
            }

            return(false);
        }