本文整理汇总了C#中IClass.GetOutgoingAssociationEnds方法的典型用法代码示例。如果您正苦于以下问题:C# IClass.GetOutgoingAssociationEnds方法的具体用法?C# IClass.GetOutgoingAssociationEnds怎么用?C# IClass.GetOutgoingAssociationEnds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IClass
的用法示例。
在下文中一共展示了IClass.GetOutgoingAssociationEnds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateClassNames
public void ValidateClassNames(ValidationContext context, IClass cls)
{
// Property and Role names must be unique within a class hierarchy.
List<string> foundNames = new List<string>();
List<IProperty> allPropertiesInHierarchy = new List<IProperty>();
List<IProperty> superRoles = new List<IProperty>();
FindAllAssocsInSuperClasses(superRoles, cls.SuperClasses);
foreach (IProperty p in cls.GetOutgoingAssociationEnds()) { superRoles.Add(p); }
foreach (IProperty p in superRoles) { allPropertiesInHierarchy.Add(p); }
foreach (IProperty p in cls.Members) { allPropertiesInHierarchy.Add(p); }
foreach (IProperty attribute in allPropertiesInHierarchy)
{
string name = attribute.Name;
if (!string.IsNullOrEmpty(name) && foundNames.Contains(name))
{
context.LogError(
string.Format("Duplicate property or role name '{0}' in class '{1}'", name, cls.Name),
"001", cls);
}
foundNames.Add(name);
}
}
示例2: AssociationTableProcessing
private void AssociationTableProcessing(IStereotypeInstance table, IClass cls)
{
foreach (IProperty p in cls.Members)
{
IEnumerable<IStereotypeInstance> columns = p.AppliedStereotypes.Where(s => s.Name == "Column");
foreach (IStereotypeInstance column in columns)
{
_py.AddProperty(p);
_sql.AddProperty(p);
}
}
List<string> unique = new List<string>();
foreach (IProperty ae in cls.GetOutgoingAssociationEnds())
{
IAssociation association = ae.Association;
IEnumerable<IProperty> comps = association.MemberEnds.Where(s => s.IsComposite && s.Name == ae.Name);
foreach (IProperty pComp in comps)
{
_py.AddCompositeProperty(pComp);
_sql.AddCompositeProperty(pComp);
unique.Add(pComp.Name);
}
IEnumerable<IStereotypeInstance> fks = association.AppliedStereotypes.Where(s => s.Name == "ForeignKey");
foreach (IStereotypeInstance fk in fks)
{
if (IsNavigableAssoc(ae) && fk != null)
{
unique.Add(ae.Name + "Id");
_py.AddFKProperty(ae);
_sql.AddFKProperty(ae);
_sql.AddFKConstraint(association.Name, cls.Name, ae.Name, ae.Type.Name, TableKeys[ae.Type.Name], UmlHelper.GetDeleteAction(fk));
}
}
IEnumerable<IStereotypeInstance> ars = association.AppliedStereotypes.Where(s => s.Name == "AbstractReference");
foreach (IStereotypeInstance ar in ars)
{
if (IsNavigableAssoc(ae))
{
_sql.AddAbstractReferenceProperty(ae);
_sql.AddIndexConstraint(ae.Name + "AbstractRefIndex", ae.Name + "Id, " + ae.Name + "Table", "");
_py.AddAbstractReferenceProperty(ae);
unique.Add(ae.Name + "Id, " + ae.Name + "Table");
}
}
IEnumerable<IStereotypeInstance> refs = association.AppliedStereotypes.Where(s => s.Name == "Reference");
foreach (IStereotypeInstance r in refs)
{
DealWithReflexiveReferences(ae, association);
unique.Add(ae.Name + "Id");
}
}
_sql.AddUniqueConstraint(unique);
}
示例3: ValidateTableHierarchAssociations
public void ValidateTableHierarchAssociations(ValidationContext context, IClass cls)
{
// All Classes that are TableHierarchies must have exactly one Parent and Child Association
IEnumerable<IStereotypeInstance> classKinds = cls.AppliedStereotypes.Where(s => s.Name == "TableHierarchy");
foreach (IStereotypeInstance classKind in classKinds)
{
int parentCount = 0; int childCount = 0;
foreach (IProperty prop in cls.GetOutgoingAssociationEnds())
{
IAssociation assoc = prop.Association;
IEnumerable<IStereotypeInstance> kindsParent = assoc.AppliedStereotypes.Where(s => s.Name == "Parent");
IEnumerable<IStereotypeInstance> kindsChild = assoc.AppliedStereotypes.Where(s => s.Name == "Child");
parentCount += kindsParent.Count();
childCount += kindsChild.Count();
}
if (!(parentCount == 1 && childCount == 1))
{
context.LogError(
string.Format("Class '{0}' is a TableHierarchy so must not have exactly one Parent and Child association type", cls.Name),
"0012", cls);
}
}
}
示例4: HierarchyTableProcessing
private void HierarchyTableProcessing(IStereotypeInstance table, IClass cls)
{
String childName = String.Empty;
String parentName = String.Empty;
String kindName = String.Empty;
foreach (IProperty p in cls.Members)
{
IEnumerable<IStereotypeInstance> columns = p.AppliedStereotypes.Where(s => s.Name == "Column");
foreach (IStereotypeInstance column in columns)
{
_py.AddProperty(p);
_sql.AddProperty(p);
}
}
foreach (IProperty p in cls.GetOutgoingAssociationEnds())
{
IAssociation association = p.Association;
IEnumerable<IStereotypeInstance> parent = association.AppliedStereotypes.Where(s => s.Name == "Parent");
foreach (IStereotypeInstance fk in parent)
{
//kindName is the Table kind for which this table is a hierarchy
kindName = association.EndTypes.Where(s => s.Name != cls.Name).First().Name;
if (IsNavigableAssoc(p) && fk != null)
{
parentName = p.Name + "Id";
_py.AddFKProperty(p);
_sql.AddFKProperty(p);
_sql.AddFKConstraint(association.Name, cls.Name, p.Name, p.Type.Name, TableKeys[p.Type.Name], "Delete");
}
}
IEnumerable<IStereotypeInstance> child = association.AppliedStereotypes.Where(s => s.Name == "Child");
foreach (IStereotypeInstance fk in child)
{
if (IsNavigableAssoc(p) && fk != null)
{
childName = p.Name + "Id";
_py.AddFKProperty(p);
_sql.AddFKProperty(p);
_sql.AddFKConstraint(association.Name, cls.Name, p.Name, p.Type.Name, TableKeys[p.Type.Name], "Delete");
}
}
}
_sql.AddIndexConstraint(cls.Name + "Index", parentName + ", " + childName, "");
_sql.AddSubtreeProcedure(cls.Name, kindName, parentName, childName);
}