/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (Title != null) { hashCode = hashCode * 59 + Title.GetHashCode(); } if (GivenName != null) { hashCode = hashCode * 59 + GivenName.GetHashCode(); } if (FamilyName != null) { hashCode = hashCode * 59 + FamilyName.GetHashCode(); } if (MiddleName != null) { hashCode = hashCode * 59 + MiddleName.GetHashCode(); } if (Href != null) { hashCode = hashCode * 59 + Href.GetHashCode(); } if (Gender != null) { hashCode = hashCode * 59 + Gender.GetHashCode(); } if (PlaceOfBirth != null) { hashCode = hashCode * 59 + PlaceOfBirth.GetHashCode(); } if (CountryOfBirth != null) { hashCode = hashCode * 59 + CountryOfBirth.GetHashCode(); } if (Nationality != null) { hashCode = hashCode * 59 + Nationality.GetHashCode(); } if (MaritalStatus != null) { hashCode = hashCode * 59 + MaritalStatus.GetHashCode(); } if (BirthDate != null) { hashCode = hashCode * 59 + BirthDate.GetHashCode(); } if (FullName != null) { hashCode = hashCode * 59 + FullName.GetHashCode(); } if (FormattedName != null) { hashCode = hashCode * 59 + FormattedName.GetHashCode(); } if (Location != null) { hashCode = hashCode * 59 + Location.GetHashCode(); } if (Status != null) { hashCode = hashCode * 59 + Status.GetHashCode(); } return(hashCode); } }
public MetaMethod(Node node, MetaClass metaClass) : base(node) { IsConstructor = node.Attributes.ContainsKey("isCtor") && node.GetAttributeValue("isCtor") == "True"; if (IsConstructor) { Name = metaClass.Name; FormattedName = Name; ReturnType = ""; } else { FormattedName = StringUtils.CapitalizeFirstLetter(FormattedName.Replace("$", "")); } IsStatic = node.Attributes.ContainsKey("isStatic") && node.GetAttributeValue("isStatic") == "True"; AccessType = node.GetAttributeValue("access"); if (AccessType == null) { AccessType = "public"; } Parameters = new List <MetaMethodParameter>(); var paramsNode = node.GetChildByType(NodeType.Params); if (paramsNode != null) { foreach (var el in paramsNode.Children) { Parameters.Add(new MetaMethodParameter(el)); } } // Make all parameters following the optional ones to also be optional (not always the case) bool hasOptional = false; foreach (var parameter in Parameters) { if (parameter.DefaultValue != null) { hasOptional = true; } else if (hasOptional) { parameter.DefaultValue = "null"; parameter.FormatDefaultValue(); } } // Get the return / parameter type from the relevant property (if there is one) var fromProperty = node.GetAttributeValue("fromProperty"); if (fromProperty != null) { var property = metaClass.Properties.FirstOrDefault(p => p.Name == fromProperty); if (property != null) { if (Name.StartsWith("get")) { ReturnType = property.Type; } else if (Name.StartsWith("set")) { Parameters[0].Type = property.Type; } } } // Get return type from the metadata if (ReturnType == null && fromProperty == null) { var returnNode = node.GetChildByType(NodeType.Return); if (returnNode != null) { var typesNode = returnNode.GetChildByType(NodeType.Types); if (typesNode != null) { // There could be more than one return type, in which case make it an object if (typesNode.Children.Count == 1) { ReturnType = typesNode.Children[0].GetAttributeValue("type"); } else { // If only one of the return types is non-null, set it as a return type // otherwise set the return type to object var nonNullTypes = new List <string>(); foreach (var typeNode in typesNode.Children) { var type = typeNode.GetAttributeValue("type"); if (type != "null") { nonNullTypes.Add(type); } } if (nonNullTypes.Count == 1) { ReturnType = nonNullTypes[0]; } else { ReturnType = "object"; } } } var commentNode = returnNode.GetChildByType(NodeType.Desc); if (commentNode != null) { ReturnComment = commentNode.GetAttributeValue("text"); } } } if (ReturnType == "null") { ReturnType = "object"; } if (!IsConstructor) { if (ReturnType == null) { ReturnType = "void"; } else { ReturnType = TypeMapper.MapType(ReturnType); } } }
/// <summary> /// Returns true if Individual instances are equal /// </summary> /// <param name="other">Instance of Individual to be compared</param> /// <returns>Boolean</returns> public bool Equals(Individual other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( Title == other.Title || Title != null && Title.Equals(other.Title) ) && ( GivenName == other.GivenName || GivenName != null && GivenName.Equals(other.GivenName) ) && ( FamilyName == other.FamilyName || FamilyName != null && FamilyName.Equals(other.FamilyName) ) && ( MiddleName == other.MiddleName || MiddleName != null && MiddleName.Equals(other.MiddleName) ) && ( Href == other.Href || Href != null && Href.Equals(other.Href) ) && ( Gender == other.Gender || Gender != null && Gender.Equals(other.Gender) ) && ( PlaceOfBirth == other.PlaceOfBirth || PlaceOfBirth != null && PlaceOfBirth.Equals(other.PlaceOfBirth) ) && ( CountryOfBirth == other.CountryOfBirth || CountryOfBirth != null && CountryOfBirth.Equals(other.CountryOfBirth) ) && ( Nationality == other.Nationality || Nationality != null && Nationality.Equals(other.Nationality) ) && ( MaritalStatus == other.MaritalStatus || MaritalStatus != null && MaritalStatus.Equals(other.MaritalStatus) ) && ( BirthDate == other.BirthDate || BirthDate != null && BirthDate.Equals(other.BirthDate) ) && ( FullName == other.FullName || FullName != null && FullName.Equals(other.FullName) ) && ( FormattedName == other.FormattedName || FormattedName != null && FormattedName.Equals(other.FormattedName) ) && ( Location == other.Location || Location != null && Location.Equals(other.Location) ) && ( Status == other.Status || Status != null && Status.Equals(other.Status) )); }
public override int GetHashCode() { return(FormattedName.GetHashCode()); }