bool MemberHasValue(XmlTypeMapMember member, object ob, bool isValueList) { if (isValueList) { return(member.GlobalIndex < ((object[])ob).Length); } else if (member.DefaultValue != System.DBNull.Value) { object val = GetMemberValue(member, ob, isValueList); if (val == null && member.DefaultValue == null) { return(false); } if (val != null && val.GetType().IsEnum) { if (val.Equals(member.DefaultValue)) { return(false); } Type t = Enum.GetUnderlyingType(val.GetType()); val = Convert.ChangeType(val, t); } if (val != null && val.Equals(member.DefaultValue)) { return(false); } } else if (member.IsOptionalValueType) { return(member.GetValueSpecified(ob)); } return(true); }
private bool MemberHasValue(XmlTypeMapMember member, object ob, bool isValueList) { if (isValueList) { return(member.GlobalIndex < ((object[])ob).Length); } if (member.DefaultValue != DBNull.Value) { object obj = this.GetMemberValue(member, ob, isValueList); if (obj == null && member.DefaultValue == null) { return(false); } if (obj != null && obj.GetType().IsEnum) { if (obj.Equals(member.DefaultValue)) { return(false); } Type underlyingType = Enum.GetUnderlyingType(obj.GetType()); obj = Convert.ChangeType(obj, underlyingType); } if (obj != null && obj.Equals(member.DefaultValue)) { return(false); } } else if (member.IsOptionalValueType) { return(member.GetValueSpecified(ob)); } return(true); }
bool MemberHasValue (XmlTypeMapMember member, object ob, bool isValueList) { if (isValueList) { if (member.IsOptionalValueType && !member.GetValueSpecified (ob)) return false; return member.GlobalIndex < ((object[])ob).Length; } else if (member.DefaultValue != System.DBNull.Value) { object val = GetMemberValue (member, ob, isValueList); if (val == null && member.DefaultValue == null) return false; if (val != null && val.GetType().IsEnum) { if (val.Equals (member.DefaultValue)) return false; Type t = Enum.GetUnderlyingType(val.GetType()); val = Convert.ChangeType (val, t); } if (val != null && val.Equals (member.DefaultValue)) return false; } else if (member.IsOptionalValueType) return member.GetValueSpecified (ob); return true; }