ThrowValueTypeCannotBeNull() public static method

This is intended to MsgPack for CLI internal use. Do not use this type from application directly. Throws an exception to notify that value type cannot be null on deserialization.
Always thrown.
public static ThrowValueTypeCannotBeNull ( string name, Type memberType, Type declaringType ) : void
name string The name of the member.
memberType System.Type The type of the member.
declaringType System.Type The type that declares the member.
return void
示例#1
0
        public static T ConvertWithEnsuringNotNull <T>(object boxed, string name, Type targetType)
        {
            if (typeof(T).GetIsValueType() && boxed == null && Nullable.GetUnderlyingType(typeof(T)) == null)
            {
                SerializationExceptions.ThrowValueTypeCannotBeNull(name, typeof(T), targetType);
            }

            return(( T )boxed);
        }
        private static void VerifyNilImplication(Type type, IEnumerable <SerializingMember> entries)
        {
            foreach (var serializingMember in entries)
            {
                if (serializingMember.Contract.NilImplication == NilImplication.Null)
                {
                    var itemType = serializingMember.Member.GetMemberValueType();

                    if (itemType != typeof(MessagePackObject) &&
                        itemType.GetIsValueType() &&
                        Nullable.GetUnderlyingType(itemType) == null)
                    {
                        SerializationExceptions.ThrowValueTypeCannotBeNull(serializingMember.Member.ToString(), itemType, type);
                    }

                    bool         isReadOnly;
                    FieldInfo    asField;
                    PropertyInfo asProperty;
                    if ((asField = serializingMember.Member as FieldInfo) != null)
                    {
                        isReadOnly = asField.IsInitOnly;
                    }
                    else
                    {
                        asProperty = serializingMember.Member as PropertyInfo;
#if DEBUG
                        Contract.Assert(asProperty != null, serializingMember.Member.ToString());
#endif // DEBUG
                        isReadOnly = asProperty.GetSetMethod() == null;
                    }

                    if (isReadOnly)
                    {
                        SerializationExceptions.ThrowNullIsProhibited(serializingMember.Member.ToString());
                    }
                }
            }
        }