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::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase) { if (target is global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase) { global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase sourceAccepted = (global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase)source; global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase targetAccepted = (global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase)target; DslModeling::ElementLink result = new global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBaseHasBaseType(sourceAccepted, targetAccepted); if (DslModeling::DomainClassInfo.HasNameProperty(result)) { DslModeling::DomainClassInfo.SetUniqueName(result); } return(result); } } if (source is global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface) { if (target is global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface) { global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface sourceAccepted = (global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface)source; global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface targetAccepted = (global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface)target; DslModeling::ElementLink result = new global::TXSoftware.DataObjectsNetEntityModel.Dsl.InterfaceInheritInterfaces(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(); }
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::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase) { if (candidateTarget is global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase) { global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase sourceEntityBase = (global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase)candidateSource; global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase targetEntityBase = (global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBase)candidateTarget; // Add a custom method to your code with the following signature: // private static bool CanAcceptEntityBaseAndEntityBaseAsSourceAndTarget(EntityBase sourceEntityBase, EntityBase targetEntityBase) // { // } if (!CanAcceptEntityBaseAndEntityBaseAsSourceAndTarget(sourceEntityBase, targetEntityBase)) { return(false); } if (sourceEntityBase == null || global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBaseHasBaseType.GetLinkToBaseType(sourceEntityBase) != null) { return(false); } if (targetEntityBase == null || sourceEntityBase == null || global::TXSoftware.DataObjectsNetEntityModel.Dsl.EntityBaseHasBaseType.GetLinks(sourceEntityBase, targetEntityBase).Count > 0) { return(false); } return(true); } } if (candidateSource is global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface) { if (candidateTarget is global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface) { global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface sourceInterface = (global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface)candidateSource; global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface targetInterface = (global::TXSoftware.DataObjectsNetEntityModel.Dsl.Interface)candidateTarget; // Add a custom method to your code with the following signature: // private static bool CanAcceptInterfaceAndInterfaceAsSourceAndTarget(Interface sourceInterface, Interface targetInterface) // { // } if (!CanAcceptInterfaceAndInterfaceAsSourceAndTarget(sourceInterface, targetInterface)) { return(false); } if (targetInterface == null || sourceInterface == null || global::TXSoftware.DataObjectsNetEntityModel.Dsl.InterfaceInheritInterfaces.GetLinks(sourceInterface, targetInterface).Count > 0) { return(false); } return(true); } } } return(false); }