public static DslModeling::ElementLink Connect(DslModeling::ModelElement source, DslModeling::ModelElement target) { if (source == null) { throw new global::System.ArgumentNullException("source"); } if (target == null) { throw new global::System.ArgumentNullException("target"); } if (CanAcceptSourceAndTarget(source, target)) { if (source is global::AgileFx.AgileModeler.ModelClass) { if (target is global::AgileFx.AgileModeler.ModelClass) { global::AgileFx.AgileModeler.ModelClass sourceAccepted = (global::AgileFx.AgileModeler.ModelClass)source; global::AgileFx.AgileModeler.ModelClass targetAccepted = (global::AgileFx.AgileModeler.ModelClass)target; DslModeling::ElementLink result = new global::AgileFx.AgileModeler.Association(sourceAccepted, targetAccepted); if (DslModeling::DomainClassInfo.HasNameProperty(result)) { DslModeling::DomainClassInfo.SetUniqueName(result); } return(result); } } } global::System.Diagnostics.Debug.Fail("Having agreed that the connection can be accepted we should never fail to make one."); throw new global::System.InvalidOperationException(); }
internal static global::System.Collections.IList GetElementsFromModelClassForNavigationPropertiesCompartment(DslModeling::ModelElement element) { global::AgileFx.AgileModeler.ModelClass root = (global::AgileFx.AgileModeler.ModelClass)element; // Segments 0 and 1 DslModeling::LinkedElementCollection <global::AgileFx.AgileModeler.NavigationProperty> result = root.NavigationProperties; return(result); }
public static bool CanAcceptSourceAndTarget(DslModeling::ModelElement candidateSource, DslModeling::ModelElement candidateTarget) { // Accepts null, null; source, null; source, target but NOT null, target if (candidateSource == null) { if (candidateTarget != null) { throw new global::System.ArgumentNullException("candidateSource"); } else // Both null { return(false); } } bool acceptSource = CanAcceptSource(candidateSource); // If the source wasn't accepted then there's no point checking targets. // If there is no target then the source controls the accept. if (!acceptSource || candidateTarget == null) { return(acceptSource); } else // Check combinations { if (candidateSource is global::AgileFx.AgileModeler.ModelClass) { if (candidateTarget is global::AgileFx.AgileModeler.ModelClass) { global::AgileFx.AgileModeler.ModelClass sourceModelClass = (global::AgileFx.AgileModeler.ModelClass)candidateSource; global::AgileFx.AgileModeler.ModelClass targetModelClass = (global::AgileFx.AgileModeler.ModelClass)candidateTarget; if (targetModelClass == null || global::AgileFx.AgileModeler.Inheritance.GetLinkToBaseclass(targetModelClass) != null) { return(false); } if (targetModelClass == null || sourceModelClass == null || global::AgileFx.AgileModeler.Inheritance.GetLinks(sourceModelClass, targetModelClass).Count > 0) { return(false); } return(true); } } } return(false); }