private static MatchLevel Compare(Type thisSideType, Association thisSide, Type otherSideType, Association otherSide) { MatchLevel noMatch = MatchLevel.NoMatch; if (((thisSide.IsForeignKey == true) && (otherSide.IsForeignKey != true)) || ((thisSide.IsForeignKey != true) && (otherSide.IsForeignKey == true))) { noMatch = noMatch; } if (thisSideType.Name == otherSide.Type) { noMatch |= MatchLevel.ThisTypeAgrees; } if (otherSideType.Name == thisSide.Type) { noMatch |= MatchLevel.OtherTypeAgrees; } if (BuildKeyField(thisSide.GetOtherKey()) == BuildKeyField(otherSide.GetThisKey())) { noMatch |= MatchLevel.ThisOtherKeyMatchesOtherThisKey; } if (BuildKeyField(thisSide.GetThisKey()) == BuildKeyField(otherSide.GetOtherKey())) { noMatch |= MatchLevel.ThisThisKeyMatchisOtherOtherKey; } return noMatch; }
private static MatchLevel Compare(Type thisSideType, Association thisSide, Type otherSideType, Association otherSide) { MatchLevel noMatch = MatchLevel.NoMatch; if (((thisSide.IsForeignKey == true) && (otherSide.IsForeignKey != true)) || ((thisSide.IsForeignKey != true) && (otherSide.IsForeignKey == true))) { noMatch = noMatch; } if (thisSideType.Name == otherSide.Type) { noMatch |= MatchLevel.ThisTypeAgrees; } if (otherSideType.Name == thisSide.Type) { noMatch |= MatchLevel.OtherTypeAgrees; } if (BuildKeyField(thisSide.GetOtherKey()) == BuildKeyField(otherSide.GetThisKey())) { noMatch |= MatchLevel.ThisOtherKeyMatchesOtherThisKey; } if (BuildKeyField(thisSide.GetThisKey()) == BuildKeyField(otherSide.GetOtherKey())) { noMatch |= MatchLevel.ThisThisKeyMatchisOtherOtherKey; } return(noMatch); }
public override Association VisitAssociation(Association association) { if (association == null) { return(null); } if (association.AccessModifier.HasValue && association.AccessModifier.Value == AccessModifier.Public) { association.AccessModifier = null; } if (association.IsForeignKey == false) { association.IsForeignKey = null; } if (association.Cardinality.HasValue && association.Cardinality.Value == Cardinality.One && association.IsForeignKey == true) { association.Cardinality = null; } if (association.Cardinality.HasValue && association.Cardinality.Value == Cardinality.Many && association.IsForeignKey != true) { association.Cardinality = null; } if ((association.Member != null) && (association.Storage == ("_" + association.Member))) { association.Storage = null; } if (association.IsForeignKey != true) { Association otherAssociation = associationPartners[association]; if (otherAssociation != null) { Type type = TypeFromTypeName(otherAssociation.Type); if ((type != null) && IsPrimaryKeyOfType(type, association.GetThisKey())) { association.SetThisKey(null); } } } if (association.IsForeignKey == true) { Type type = TypeFromTypeName(association.Type); if ((type != null) && IsPrimaryKeyOfType(type, association.GetOtherKey())) { association.SetOtherKey(null); } } return(association); }
public override Association VisitAssociation(Association association) { if (association == null) { return(null); } if (!association.AccessModifier.HasValue) { association.AccessModifier = 0; } if (!association.IsForeignKey.HasValue) { association.IsForeignKey = false; } if (!association.Cardinality.HasValue) { association.Cardinality = association.IsForeignKey == true ? 0 : (Cardinality)1; } if (!association.DeleteOnNull.HasValue) { association.DeleteOnNull = false; } if (association.Storage == null) { association.Storage = "_" + association.Member; } if ((association.GetThisKey().Length == 0) && (association.IsForeignKey != true)) { Association other = associationPartners[association]; if (other != null) { Type type = TypeFromTypeName(other.Type); if (type != null) { association.SetThisKey(GetPrimaryKeys(type)); } } } if ((association.GetOtherKey().Length == 0) && (association.IsForeignKey == true)) { Type type2 = TypeFromTypeName(association.Type); if (type2 != null) { association.SetOtherKey(GetPrimaryKeys(type2)); } } return(association); }
public override Association VisitAssociation(Association association) { if (association == null) return null; writer.WriteStartElement("Association"); if (association.Name != null) writer.WriteAttributeString("Name", association.Name); if (association.Member != null) writer.WriteAttributeString("Member", association.Member); if (association.Storage != null) writer.WriteAttributeString("Storage", association.Storage); if (association.AccessModifier.HasValue) writer.WriteAttributeString("AccessModifier", association.AccessModifier.ToString()); if (association.Modifier.HasValue) writer.WriteAttributeString("Modifier", association.Modifier.ToString()); string thisKey = BuildKeyField(association.GetThisKey()); if (!string.IsNullOrEmpty(thisKey)) writer.WriteAttributeString("ThisKey", thisKey); string otherKey = BuildKeyField(association.GetOtherKey()); if (!string.IsNullOrEmpty(otherKey)) writer.WriteAttributeString("OtherKey", otherKey); if (association.Type != null) writer.WriteAttributeString("Type", association.Type); if (association.IsForeignKey.HasValue) writer.WriteAttributeString("IsForeignKey", ToXmlBooleanString(association.IsForeignKey)); if (association.Cardinality.HasValue) writer.WriteAttributeString("Cardinality", association.Cardinality.ToString()); if (association.DeleteRule != null) writer.WriteAttributeString("DeleteRule", association.DeleteRule); if (association.DeleteOnNull.HasValue) writer.WriteAttributeString("DeleteOnNull", ToXmlBooleanString(association.DeleteOnNull)); writer.WriteEndElement(); return association; }
public override Association VisitAssociation(Association association) { if (association == null) return null; var a = new Association(association.Name) { Member = association.Member, Storage = association.Storage, AccessModifier = association.AccessModifier, Modifier = association.Modifier }; a.SetThisKey(association.GetThisKey()); a.SetOtherKey(association.GetOtherKey()); a.IsForeignKey = association.IsForeignKey; a.Cardinality = association.Cardinality; a.DeleteOnNull = association.DeleteOnNull; a.DeleteRule = association.DeleteRule; a.Type = association.Type; return a; }
public override Association VisitAssociation(Association association) { if (association == null) return null; if (association.AccessModifier.HasValue && association.AccessModifier.Value == AccessModifier.Public) association.AccessModifier = null; if (association.IsForeignKey == false) association.IsForeignKey = null; if (association.Cardinality.HasValue && association.Cardinality.Value == Cardinality.One && association.IsForeignKey == true) association.Cardinality = null; if (association.Cardinality.HasValue && association.Cardinality.Value == Cardinality.Many && association.IsForeignKey != true) association.Cardinality = null; if ((association.Member != null) && (association.Storage == ("_" + association.Member))) association.Storage = null; if (association.IsForeignKey != true) { Association otherAssociation = associationPartners[association]; if (otherAssociation != null) { Type type = TypeFromTypeName(otherAssociation.Type); if ((type != null) && IsPrimaryKeyOfType(type, association.GetThisKey())) association.SetThisKey(null); } } if (association.IsForeignKey == true) { Type type = TypeFromTypeName(association.Type); if ((type != null) && IsPrimaryKeyOfType(type, association.GetOtherKey())) association.SetOtherKey(null); } return association; }
public override Association VisitAssociation(Association association) { if (association == null) return null; if (!association.AccessModifier.HasValue) association.AccessModifier = 0; if (!association.IsForeignKey.HasValue) association.IsForeignKey = false; if (!association.Cardinality.HasValue) association.Cardinality = association.IsForeignKey == true ? 0 : (Cardinality) 1; if (!association.DeleteOnNull.HasValue) association.DeleteOnNull = false; if (association.Storage == null) association.Storage = "_" + association.Member; if ((association.GetThisKey().Length == 0) && (association.IsForeignKey != true)) { Association other = associationPartners[association]; if (other != null) { Type type = TypeFromTypeName(other.Type); if (type != null) association.SetThisKey(GetPrimaryKeys(type)); } } if ((association.GetOtherKey().Length == 0) && (association.IsForeignKey == true)) { Type type2 = TypeFromTypeName(association.Type); if (type2 != null) association.SetOtherKey(GetPrimaryKeys(type2)); } return association; }
public override Association VisitAssociation(Association association) { if (association == null) { return(null); } var a = new Association(association.Name) { Member = association.Member, Storage = association.Storage, AccessModifier = association.AccessModifier, Modifier = association.Modifier }; a.SetThisKey(association.GetThisKey()); a.SetOtherKey(association.GetOtherKey()); a.IsForeignKey = association.IsForeignKey; a.Cardinality = association.Cardinality; a.DeleteOnNull = association.DeleteOnNull; a.DeleteRule = association.DeleteRule; a.Type = association.Type; return(a); }
public override Association VisitAssociation(Association association) { if (association == null) { return(null); } writer.WriteStartElement("Association"); if (association.Name != null) { writer.WriteAttributeString("Name", association.Name); } if (association.Member != null) { writer.WriteAttributeString("Member", association.Member); } if (association.Storage != null) { writer.WriteAttributeString("Storage", association.Storage); } if (association.AccessModifier.HasValue) { writer.WriteAttributeString("AccessModifier", association.AccessModifier.ToString()); } if (association.Modifier.HasValue) { writer.WriteAttributeString("Modifier", association.Modifier.ToString()); } string thisKey = BuildKeyField(association.GetThisKey()); if (!string.IsNullOrEmpty(thisKey)) { writer.WriteAttributeString("ThisKey", thisKey); } string otherKey = BuildKeyField(association.GetOtherKey()); if (!string.IsNullOrEmpty(otherKey)) { writer.WriteAttributeString("OtherKey", otherKey); } if (association.Type != null) { writer.WriteAttributeString("Type", association.Type); } if (association.IsForeignKey.HasValue) { writer.WriteAttributeString("IsForeignKey", ToXmlBooleanString(association.IsForeignKey)); } if (association.Cardinality.HasValue) { writer.WriteAttributeString("Cardinality", association.Cardinality.ToString()); } if (association.DeleteRule != null) { writer.WriteAttributeString("DeleteRule", association.DeleteRule); } if (association.DeleteOnNull.HasValue) { writer.WriteAttributeString("DeleteOnNull", ToXmlBooleanString(association.DeleteOnNull)); } writer.WriteEndElement(); return(association); }