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::NuPattern.Authoring.WorkflowDesign.ProducedAsset) { if (candidateTarget is global::NuPattern.Authoring.WorkflowDesign.ProductionTool) { global::NuPattern.Authoring.WorkflowDesign.ProducedAsset sourceProducedAsset = (global::NuPattern.Authoring.WorkflowDesign.ProducedAsset)candidateSource; global::NuPattern.Authoring.WorkflowDesign.ProductionTool targetProductionTool = (global::NuPattern.Authoring.WorkflowDesign.ProductionTool)candidateTarget; if (targetProductionTool == null || sourceProducedAsset == null || global::NuPattern.Authoring.WorkflowDesign.ProducedAssetSuppliesProductionTools.GetLinks(sourceProducedAsset, targetProductionTool).Count > 0) { return(false); } return(true); } } if (candidateSource is global::NuPattern.Authoring.WorkflowDesign.SuppliedAsset) { if (candidateTarget is global::NuPattern.Authoring.WorkflowDesign.ProducedAsset) { global::NuPattern.Authoring.WorkflowDesign.SuppliedAsset sourceSuppliedAsset = (global::NuPattern.Authoring.WorkflowDesign.SuppliedAsset)candidateSource; global::NuPattern.Authoring.WorkflowDesign.ProducedAsset targetProducedAsset = (global::NuPattern.Authoring.WorkflowDesign.ProducedAsset)candidateTarget; if (targetProducedAsset == null || sourceSuppliedAsset == null || global::NuPattern.Authoring.WorkflowDesign.SuppliedAssetCopiesToProducedAssets.GetLinks(sourceSuppliedAsset, targetProducedAsset).Count > 0) { return(false); } return(true); } else if (candidateTarget is global::NuPattern.Authoring.WorkflowDesign.ProductionTool) { global::NuPattern.Authoring.WorkflowDesign.SuppliedAsset sourceSuppliedAsset = (global::NuPattern.Authoring.WorkflowDesign.SuppliedAsset)candidateSource; global::NuPattern.Authoring.WorkflowDesign.ProductionTool targetProductionTool = (global::NuPattern.Authoring.WorkflowDesign.ProductionTool)candidateTarget; if (targetProductionTool == null || sourceSuppliedAsset == null || global::NuPattern.Authoring.WorkflowDesign.SuppliedAssetSuppliesProductionTools.GetLinks(sourceSuppliedAsset, targetProductionTool).Count > 0) { return(false); } return(true); } } if (candidateSource is global::NuPattern.Authoring.WorkflowDesign.ProductionTool) { if (candidateTarget is global::NuPattern.Authoring.WorkflowDesign.ProducedAsset) { global::NuPattern.Authoring.WorkflowDesign.ProductionTool sourceProductionTool = (global::NuPattern.Authoring.WorkflowDesign.ProductionTool)candidateSource; global::NuPattern.Authoring.WorkflowDesign.ProducedAsset targetProducedAsset = (global::NuPattern.Authoring.WorkflowDesign.ProducedAsset)candidateTarget; if (targetProducedAsset == null || sourceProductionTool == null || global::NuPattern.Authoring.WorkflowDesign.ProductionToolProducesProducedAssets.GetLinks(sourceProductionTool, targetProducedAsset).Count > 0) { return(false); } return(true); } else if (candidateTarget is global::NuPattern.Authoring.WorkflowDesign.VariabilityRequirement) { global::NuPattern.Authoring.WorkflowDesign.ProductionTool sourceProductionTool = (global::NuPattern.Authoring.WorkflowDesign.ProductionTool)candidateSource; global::NuPattern.Authoring.WorkflowDesign.VariabilityRequirement targetVariabilityRequirement = (global::NuPattern.Authoring.WorkflowDesign.VariabilityRequirement)candidateTarget; if (targetVariabilityRequirement == null || sourceProductionTool == null || global::NuPattern.Authoring.WorkflowDesign.ProductionToolReferencesVariabilityRequirements.GetLinks(sourceProductionTool, targetVariabilityRequirement).Count > 0) { return(false); } return(true); } } } return(false); }
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::NuPattern.Authoring.WorkflowDesign.ProducedAsset) { if (target is global::NuPattern.Authoring.WorkflowDesign.ProductionTool) { global::NuPattern.Authoring.WorkflowDesign.ProducedAsset sourceAccepted = (global::NuPattern.Authoring.WorkflowDesign.ProducedAsset)source; global::NuPattern.Authoring.WorkflowDesign.ProductionTool targetAccepted = (global::NuPattern.Authoring.WorkflowDesign.ProductionTool)target; DslModeling::ElementLink result = new global::NuPattern.Authoring.WorkflowDesign.ProducedAssetSuppliesProductionTools(sourceAccepted, targetAccepted); if (DslModeling::DomainClassInfo.HasNameProperty(result)) { DslModeling::DomainClassInfo.SetUniqueName(result); } return(result); } } if (source is global::NuPattern.Authoring.WorkflowDesign.SuppliedAsset) { if (target is global::NuPattern.Authoring.WorkflowDesign.ProducedAsset) { global::NuPattern.Authoring.WorkflowDesign.SuppliedAsset sourceAccepted = (global::NuPattern.Authoring.WorkflowDesign.SuppliedAsset)source; global::NuPattern.Authoring.WorkflowDesign.ProducedAsset targetAccepted = (global::NuPattern.Authoring.WorkflowDesign.ProducedAsset)target; DslModeling::ElementLink result = new global::NuPattern.Authoring.WorkflowDesign.SuppliedAssetCopiesToProducedAssets(sourceAccepted, targetAccepted); if (DslModeling::DomainClassInfo.HasNameProperty(result)) { DslModeling::DomainClassInfo.SetUniqueName(result); } return(result); } else if (target is global::NuPattern.Authoring.WorkflowDesign.ProductionTool) { global::NuPattern.Authoring.WorkflowDesign.SuppliedAsset sourceAccepted = (global::NuPattern.Authoring.WorkflowDesign.SuppliedAsset)source; global::NuPattern.Authoring.WorkflowDesign.ProductionTool targetAccepted = (global::NuPattern.Authoring.WorkflowDesign.ProductionTool)target; DslModeling::ElementLink result = new global::NuPattern.Authoring.WorkflowDesign.SuppliedAssetSuppliesProductionTools(sourceAccepted, targetAccepted); if (DslModeling::DomainClassInfo.HasNameProperty(result)) { DslModeling::DomainClassInfo.SetUniqueName(result); } return(result); } } if (source is global::NuPattern.Authoring.WorkflowDesign.ProductionTool) { if (target is global::NuPattern.Authoring.WorkflowDesign.ProducedAsset) { global::NuPattern.Authoring.WorkflowDesign.ProductionTool sourceAccepted = (global::NuPattern.Authoring.WorkflowDesign.ProductionTool)source; global::NuPattern.Authoring.WorkflowDesign.ProducedAsset targetAccepted = (global::NuPattern.Authoring.WorkflowDesign.ProducedAsset)target; DslModeling::ElementLink result = new global::NuPattern.Authoring.WorkflowDesign.ProductionToolProducesProducedAssets(sourceAccepted, targetAccepted); if (DslModeling::DomainClassInfo.HasNameProperty(result)) { DslModeling::DomainClassInfo.SetUniqueName(result); } return(result); } else if (target is global::NuPattern.Authoring.WorkflowDesign.VariabilityRequirement) { global::NuPattern.Authoring.WorkflowDesign.ProductionTool sourceAccepted = (global::NuPattern.Authoring.WorkflowDesign.ProductionTool)source; global::NuPattern.Authoring.WorkflowDesign.VariabilityRequirement targetAccepted = (global::NuPattern.Authoring.WorkflowDesign.VariabilityRequirement)target; DslModeling::ElementLink result = new global::NuPattern.Authoring.WorkflowDesign.ProductionToolReferencesVariabilityRequirements(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(); }