System.Runtime.InteropServices.StructLayoutAttribute.IsDefined C# (CSharp) Method

IsDefined() static private method

static private IsDefined ( Type type ) : bool
type Type
return bool
        internal static bool IsDefined(Type type) 
        { 
            if (type.IsInterface || type.HasElementType || type.IsGenericParameter)
                return false;
            
            return true; 
        }

Usage Example

コード例 #1
0
        internal static Attribute GetCustomAttribute(RuntimeType type)
        {
            if (!StructLayoutAttribute.IsDefined(type))
            {
                return(null);
            }
            int            num            = 0;
            int            size           = 0;
            LayoutKind     layoutKind     = LayoutKind.Auto;
            TypeAttributes typeAttributes = type.Attributes & TypeAttributes.LayoutMask;

            if (typeAttributes != TypeAttributes.NotPublic)
            {
                if (typeAttributes != TypeAttributes.SequentialLayout)
                {
                    if (typeAttributes == TypeAttributes.ExplicitLayout)
                    {
                        layoutKind = LayoutKind.Explicit;
                    }
                }
                else
                {
                    layoutKind = LayoutKind.Sequential;
                }
            }
            else
            {
                layoutKind = LayoutKind.Auto;
            }
            CharSet charSet = CharSet.None;

            typeAttributes = (type.Attributes & TypeAttributes.StringFormatMask);
            if (typeAttributes != TypeAttributes.NotPublic)
            {
                if (typeAttributes != TypeAttributes.UnicodeClass)
                {
                    if (typeAttributes == TypeAttributes.AutoClass)
                    {
                        charSet = CharSet.Auto;
                    }
                }
                else
                {
                    charSet = CharSet.Unicode;
                }
            }
            else
            {
                charSet = CharSet.Ansi;
            }
            type.GetRuntimeModule().MetadataImport.GetClassLayout(type.MetadataToken, out num, out size);
            if (num == 0)
            {
                num = 8;
            }
            return(new StructLayoutAttribute(layoutKind, num, size, charSet));
        }
All Usage Examples Of System.Runtime.InteropServices.StructLayoutAttribute::IsDefined