Example #1
0
 public DataMemberContract(MemberInfo member, MessagePackMemberAttribute attribute)
 {
     Contract.Requires(member != null);
     Contract.Requires(attribute != null);
     if (attribute.Id < 0)
     {
         throw new SerializationException(string.Format(CultureInfo.CurrentCulture, "The member ID cannot be negative. The member is '{0}' in the '{1}' type.", new object[] { member.Name, member.DeclaringType }));
     }
     this._name           = member.Name;
     this._nilImplication = attribute.NilImplication;
     this._id             = attribute.Id;
 }
        /// <summary>
        ///		Initializes a new instance of the <see cref="DataMemberContract"/> struct from <see cref="MessagePackMemberAttribute"/>.
        /// </summary>
        /// <param name="member">The target member.</param>
        /// <param name="attribute">The MessagePack member attribute.</param>
        public DataMemberContract(MemberInfo member, MessagePackMemberAttribute attribute)
        {
            Contract.Assert(member != null);
            Contract.Assert(attribute != null);

            if (attribute.Id < 0)
            {
                throw new SerializationException(String.Format(CultureInfo.CurrentCulture, "The member ID cannot be negative. The member is '{0}' in the '{1}' type.", member.Name, member.DeclaringType));
            }

            this._name           = String.IsNullOrEmpty(attribute.Name) ? member.Name : attribute.Name;
            this._nilImplication = attribute.NilImplication;
            this._id             = attribute.Id;
        }
Example #3
0
		/// <summary>
		///		Initializes a new instance of the <see cref="DataMemberContract"/> struct from <see cref="MessagePackMemberAttribute"/>.
		/// </summary>
		/// <param name="member">The target member.</param>
		/// <param name="attribute">The MessagePack member attribute.</param>
		public DataMemberContract( MemberInfo member, MessagePackMemberAttribute attribute )
		{
#if !UNITY
			Contract.Requires( member != null );
			Contract.Requires( attribute != null );
#endif // !UNITY

			if ( attribute.Id < 0 )
			{
				throw new SerializationException( String.Format( CultureInfo.CurrentCulture, "The member ID cannot be negative. The member is '{0}' in the '{1}' type.", member.Name, member.DeclaringType ) );
			}

			this._name = String.IsNullOrEmpty( attribute.Name ) ? member.Name : attribute.Name;
			this._nilImplication = attribute.NilImplication;
			this._id = attribute.Id;
		}