コード例 #1
0
        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::SPbSU.RobotsLanguage.AbstractNode)
                {
                    if (target is global::SPbSU.RobotsLanguage.AbstractNode)
                    {
                        global::SPbSU.RobotsLanguage.AbstractNode sourceAccepted = (global::SPbSU.RobotsLanguage.AbstractNode)source;
                        global::SPbSU.RobotsLanguage.AbstractNode targetAccepted = (global::SPbSU.RobotsLanguage.AbstractNode)target;
                        DslModeling::ElementLink result = new global::SPbSU.RobotsLanguage.AbstractNodeReferencesTargetAbstractNode(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();
        }
コード例 #2
0
        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::SPbSU.RobotsLanguage.AbstractNode)
                {
                    if (candidateTarget is global::SPbSU.RobotsLanguage.AbstractNode)
                    {
                        global::SPbSU.RobotsLanguage.AbstractNode sourceAbstractNode = (global::SPbSU.RobotsLanguage.AbstractNode)candidateSource;
                        global::SPbSU.RobotsLanguage.AbstractNode targetAbstractNode = (global::SPbSU.RobotsLanguage.AbstractNode)candidateTarget;
                        if (targetAbstractNode == null || sourceAbstractNode == null || global::SPbSU.RobotsLanguage.AbstractNodeReferencesTargetAbstractNode.GetLinks(sourceAbstractNode, targetAbstractNode).Count > 0)
                        {
                            return(false);
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #3
0
 public static global::SPbSU.RobotsLanguage.CompoundHasAbstractNode GetLink(global::SPbSU.RobotsLanguage.Compound source, global::SPbSU.RobotsLanguage.AbstractNode target)
 {
     global::System.Collections.Generic.IList <global::SPbSU.RobotsLanguage.CompoundHasAbstractNode> links = DslModeling::DomainRoleInfo.GetElementLinks <global::SPbSU.RobotsLanguage.CompoundHasAbstractNode>(source, global::SPbSU.RobotsLanguage.CompoundHasAbstractNode.CompoundDomainRoleId);
     foreach (global::SPbSU.RobotsLanguage.CompoundHasAbstractNode link in links)
     {
         if (target.Equals(link.AbstractNode))
         {
             return(link);
         }
     }
     return(null);
 }
コード例 #4
0
 public static global::System.Collections.ObjectModel.ReadOnlyCollection <global::SPbSU.RobotsLanguage.CompoundHasAbstractNode> GetLinks(global::SPbSU.RobotsLanguage.Compound source, global::SPbSU.RobotsLanguage.AbstractNode target)
 {
     global::System.Collections.Generic.List <global::SPbSU.RobotsLanguage.CompoundHasAbstractNode>  outLinks = new global::System.Collections.Generic.List <global::SPbSU.RobotsLanguage.CompoundHasAbstractNode>();
     global::System.Collections.Generic.IList <global::SPbSU.RobotsLanguage.CompoundHasAbstractNode> links    = DslModeling::DomainRoleInfo.GetElementLinks <global::SPbSU.RobotsLanguage.CompoundHasAbstractNode>(source, global::SPbSU.RobotsLanguage.CompoundHasAbstractNode.CompoundDomainRoleId);
     foreach (global::SPbSU.RobotsLanguage.CompoundHasAbstractNode link in links)
     {
         if (target.Equals(link.AbstractNode))
         {
             outLinks.Add(link);
         }
     }
     return(outLinks.AsReadOnly());
 }
コード例 #5
0
 public static global::SPbSU.RobotsLanguage.CompoundHasAbstractNode GetLinkToCompound(global::SPbSU.RobotsLanguage.AbstractNode abstractNodeInstance)
 {
     global::System.Collections.Generic.IList <global::SPbSU.RobotsLanguage.CompoundHasAbstractNode> links = DslModeling::DomainRoleInfo.GetElementLinks <global::SPbSU.RobotsLanguage.CompoundHasAbstractNode>(abstractNodeInstance, global::SPbSU.RobotsLanguage.CompoundHasAbstractNode.AbstractNodeDomainRoleId);
     global::System.Diagnostics.Debug.Assert(links.Count <= 1, "Multiplicity of AbstractNode not obeyed.");
     if (links.Count == 0)
     {
         return(null);
     }
     else
     {
         return(links[0]);
     }
 }
コード例 #6
0
 public static global::System.Collections.ObjectModel.ReadOnlyCollection <global::SPbSU.RobotsLanguage.AbstractNodeReferencesTargetAbstractNode> GetLinksToSourceAbstractNode(global::SPbSU.RobotsLanguage.AbstractNode targetAbstractNodeInstance)
 {
     return(DslModeling::DomainRoleInfo.GetElementLinks <global::SPbSU.RobotsLanguage.AbstractNodeReferencesTargetAbstractNode>(targetAbstractNodeInstance, global::SPbSU.RobotsLanguage.AbstractNodeReferencesTargetAbstractNode.TargetAbstractNodeDomainRoleId));
 }