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::Microsoft.Example.Circuits.Comment)
                {
                    if (target is global::Microsoft.Example.Circuits.Component)
                    {
                        global::Microsoft.Example.Circuits.Comment   sourceAccepted = (global::Microsoft.Example.Circuits.Comment)source;
                        global::Microsoft.Example.Circuits.Component targetAccepted = (global::Microsoft.Example.Circuits.Component)target;
                        DslModeling::ElementLink result = new global::Microsoft.Example.Circuits.CommentsReferenceComponents(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 global::Microsoft.Example.Circuits.Component GetParentForComponentTerminal(global::Microsoft.Example.Circuits.ComponentTerminal root)
 {
     // Segments 0 and 1
     global::Microsoft.Example.Circuits.Component result = root.Component;
     if (result == null)
     {
         return(null);
     }
     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::Microsoft.Example.Circuits.Comment)
                {
                    if (candidateTarget is global::Microsoft.Example.Circuits.Component)
                    {
                        global::Microsoft.Example.Circuits.Comment   sourceComment   = (global::Microsoft.Example.Circuits.Comment)candidateSource;
                        global::Microsoft.Example.Circuits.Component targetComponent = (global::Microsoft.Example.Circuits.Component)candidateTarget;
                        if (targetComponent == null || sourceComment == null || global::Microsoft.Example.Circuits.CommentsReferenceComponents.GetLinks(sourceComment, targetComponent).Count > 0)
                        {
                            return(false);
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #4
0
 public static global::Microsoft.Example.Circuits.ComponentModel GetParentForCapacitor(global::Microsoft.Example.Circuits.Component root)
 {
     // Segments 0 and 1
     global::Microsoft.Example.Circuits.ComponentModel result = root.ComponentModel;
     if (result == null)
     {
         return(null);
     }
     return(result);
 }