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);
            }
예제 #2
0
            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);
            }
예제 #3
0
            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;
            }
예제 #6
0
            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);
            }
예제 #7
0
            private static Association ReadAssociation(XmlTextReader reader)
            {
                ValidateAttributes(reader,
                                   new[]
                {
                    "Name", "Type", "Member", "Storage", "AccessModifier", "Modifier",
                    "IsForeignKey", "Cardinality", "DeleteOnNull", "ThisKey", "OtherKey",
                    "DeleteRule"
                });
                var    association = new Association("");
                string attribute   = reader.GetAttribute("Name");

                if (attribute == null)
                {
                    throw Error.RequiredAttributeMissingViolation("Name", reader.LineNumber);
                }
                if (reader.GetAttribute("Type") == null)
                {
                    throw Error.RequiredAttributeMissingViolation("Type", reader.LineNumber);
                }
                association.Name   = attribute;
                association.Member = reader.GetAttribute("Member");
                if (reader.GetAttribute("Member") == null)
                {
                    throw Error.RequiredAttributeMissingViolation("Member", reader.LineNumber);
                }
                association.Storage = reader.GetAttribute("Storage");
                attribute           = reader.GetAttribute("AccessModifier");
                try
                {
                    if (attribute == null)
                    {
                        association.AccessModifier = null;
                    }
                    else
                    {
                        association.AccessModifier =
                            (AccessModifier)Enum.Parse(typeof(AccessModifier), attribute, true);
                    }

                    attribute = reader.GetAttribute("Modifier");
                    if (attribute == null)
                    {
                        association.Modifier = null;
                    }
                    else
                    {
                        association.Modifier = (MemberModifier)Enum.Parse(typeof(MemberModifier), attribute, true);
                    }

                    attribute = reader.GetAttribute("IsForeignKey");
                    association.IsForeignKey = (attribute == null) ? null : new bool?(bool.Parse(attribute));

                    attribute = reader.GetAttribute("Cardinality");
                    if (attribute == null)
                    {
                        association.Cardinality = null;
                    }
                    else
                    {
                        association.Cardinality = (Cardinality)Enum.Parse(typeof(Cardinality), attribute, true);
                    }

                    attribute = reader.GetAttribute("DeleteOnNull");
                    association.DeleteOnNull = (attribute == null) ? null : new bool?(bool.Parse(attribute));
                }
                catch (FormatException)
                {
                    throw Error.InvalidBooleanAttributeValueViolation(attribute, reader.LineNumber);
                }
                catch (ArgumentException)
                {
                    throw Error.InvalidEnumAttributeValueViolation(attribute, reader.LineNumber);
                }
                association.SetThisKey(ParseKeyField(reader.GetAttribute("ThisKey")));
                association.Type = reader.GetAttribute("Type");
                association.SetOtherKey(ParseKeyField(reader.GetAttribute("OtherKey")));
                association.DeleteRule = reader.GetAttribute("DeleteRule");
                AssertEmptyElement(reader);
                return(association);
            }
예제 #8
0
파일: DbmlReader.cs 프로젝트: cmcginn/AIM
            private static Association ReadAssociation(XmlTextReader reader)
            {
                ValidateAttributes(reader,
                                   new[]
                                       {
                                           "Name", "Type", "Member", "Storage", "AccessModifier", "Modifier",
                                           "IsForeignKey", "Cardinality", "DeleteOnNull", "ThisKey", "OtherKey",
                                           "DeleteRule"
                                       });
                var association = new Association("");
                string attribute = reader.GetAttribute("Name");
                if (attribute == null)
                {
                    throw Error.RequiredAttributeMissingViolation("Name", reader.LineNumber);
                }
                if (reader.GetAttribute("Type") == null)
                {
                    throw Error.RequiredAttributeMissingViolation("Type", reader.LineNumber);
                }
                association.Name = attribute;
                association.Member = reader.GetAttribute("Member");
                if (reader.GetAttribute("Member") == null)
                {
                    throw Error.RequiredAttributeMissingViolation("Member", reader.LineNumber);
                }
                association.Storage = reader.GetAttribute("Storage");
                attribute = reader.GetAttribute("AccessModifier");
                try
                {
                    if (attribute == null)
                        association.AccessModifier = null;
                    else
                        association.AccessModifier =
                            (AccessModifier) Enum.Parse(typeof (AccessModifier), attribute, true);

                    attribute = reader.GetAttribute("Modifier");
                    if (attribute == null)
                        association.Modifier = null;
                    else
                        association.Modifier = (MemberModifier) Enum.Parse(typeof (MemberModifier), attribute, true);

                    attribute = reader.GetAttribute("IsForeignKey");
                    association.IsForeignKey = (attribute == null) ? null : new bool?(bool.Parse(attribute));

                    attribute = reader.GetAttribute("Cardinality");
                    if (attribute == null)
                        association.Cardinality = null;
                    else
                        association.Cardinality = (Cardinality) Enum.Parse(typeof (Cardinality), attribute, true);

                    attribute = reader.GetAttribute("DeleteOnNull");
                    association.DeleteOnNull = (attribute == null) ? null : new bool?(bool.Parse(attribute));
                }
                catch (FormatException)
                {
                    throw Error.InvalidBooleanAttributeValueViolation(attribute, reader.LineNumber);
                }
                catch (ArgumentException)
                {
                    throw Error.InvalidEnumAttributeValueViolation(attribute, reader.LineNumber);
                }
                association.SetThisKey(ParseKeyField(reader.GetAttribute("ThisKey")));
                association.Type = reader.GetAttribute("Type");
                association.SetOtherKey(ParseKeyField(reader.GetAttribute("OtherKey")));
                association.DeleteRule = reader.GetAttribute("DeleteRule");
                AssertEmptyElement(reader);
                return association;
            }