} // Work with classes public static bool GetMarried(THuman pearson1, THuman pearson2) { bool canMarry1 = false; bool canMarry2 = false; var relationships1 = new Relations(); var relationships2 = new Relations(); // Read Attribute [5] Type p1 = pearson1.GetType(); var attributes1 = p1.GetCustomAttributes(typeof(SocialAttitude), true); foreach (SocialAttitude attribute in attributes1) { relationships1 = attribute.Couple; } Type p2 = pearson2.GetType(); var attributes2 = p2.GetCustomAttributes(true); foreach (SocialAttitude attribute in attributes2) { relationships2 = attribute.Couple; } // If they meaning about couple identical if (!relationships1.Equals(relationships2)) { return(false); } foreach (String r in pearson1.Relationships.Keys) { if (relationships1.HasFlag((Relations)Enum.Parse(typeof(Relations), r))) { if (pearson1.Relationships[r] == pearson2.Id) { canMarry1 = true; } } } foreach (String r in pearson2.Relationships.Keys) { if (relationships1.HasFlag((Relations)Enum.Parse(typeof(Relations), r))) { if (pearson2.Relationships[r] == pearson1.Id) { canMarry2 = true; } } } return(canMarry1 & canMarry2); }