示例#1
0
        private RelationContener DrawInheritanceRelation(EntityTypeDesigner baseTypeDesigner, EntityTypeDesigner childTypeDesigner)
        {
            var relationContener = (from rc in Designer.Children.OfType <RelationContener>()
                                    let ir = rc.Content as InheritanceRelation
                                             where ir != null && ir.FromTypeDesigner == childTypeDesigner && ir.ToTypeDesigner == baseTypeDesigner
                                             select rc).FirstOrDefault();

            if (relationContener != null)
            {
                return(relationContener);
            }
            var inheritanceRelation = new InheritanceRelation(Designer, childTypeDesigner, baseTypeDesigner, () => Designer.Children.OfType <EntityTypeDesigner>().FirstOrDefault(etd => etd.EntityType.BusinessInstance == EntityType.BusinessInstance.BaseType));

            relationContener = new RelationContener(inheritanceRelation);
            Designer.Children.Add(relationContener);
            relationContener.SetBinding(Canvas.LeftProperty, new Binding {
                Source = inheritanceRelation, Path = new PropertyPath("CanvasLeft")
            });
            relationContener.SetBinding(Canvas.TopProperty, new Binding {
                Source = inheritanceRelation, Path = new PropertyPath("CanvasTop")
            });
            baseTypeDesigner.AddRelationContenerWithoutRelatedProperty(relationContener);
            childTypeDesigner.AddRelationContenerWithoutRelatedProperty(relationContener);
            return(relationContener);
        }
示例#2
0
        private void ValidateSingleInheritance(ValidationContext context)
        {
            LinkedElementCollection <ModelClass> parentClasses = InheritanceRelation.GetTargetModelClasses(this);

            if (parentClasses.Count > 1)
            {
                context.LogError(
                    string.Format(
                        "Class {0} cannot inherit from multiple classes.",
                        Name), "AW001SingleInheritanceError", this);
            }
        }