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::Company.DoubleClickOnShape.ExampleElement)
                {
                    if (target is global::Company.DoubleClickOnShape.ExampleElement)
                    {
                        global::Company.DoubleClickOnShape.ExampleElement sourceAccepted = (global::Company.DoubleClickOnShape.ExampleElement)source;
                        global::Company.DoubleClickOnShape.ExampleElement targetAccepted = (global::Company.DoubleClickOnShape.ExampleElement)target;
                        DslModeling::ElementLink result = new global::Company.DoubleClickOnShape.ExampleElementReferencesTargets(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
        /// <summary>
        /// Called by the Merge process to create a relationship between
        /// this target element and the specified source element.
        /// Typically, a parent-child relationship is established
        /// between the target element (the parent) and the source element
        /// (the child), but any relationship can be established.
        /// </summary>
        /// <param name="sourceElement">The element that is to be related to this model element.</param>
        /// <param name="elementGroup">The group of source ModelElements that have been rehydrated into the target store.</param>
        /// <remarks>
        /// This method is overriden to create the relationship between the target element and the specified source element.
        /// The base method does nothing.
        /// </remarks>
        protected override void MergeRelate(DslModeling::ModelElement sourceElement, DslModeling::ElementGroup elementGroup)
        {
            // In general, sourceElement is allowed to be null, meaning that the elementGroup must be parsed for special cases.
            // However this is not supported in generated code.  Use double-deriving on this class and then override MergeRelate completely if you
            // need to support this case.
            if (sourceElement == null)
            {
                throw new global::System.ArgumentNullException("sourceElement");
            }


            global::Company.DoubleClickOnShape.ExampleElement sourceExampleElement1 = sourceElement as global::Company.DoubleClickOnShape.ExampleElement;
            if (sourceExampleElement1 != null)
            {
                // Create link for path ExampleModelHasElements.Elements
                this.Elements.Add(sourceExampleElement1);

                return;
            }

            // Sdk workaround to runtime bug #879350 (DSL: can't copy and paste a MEL that has a MEX). Avoid MergeRelate on ModelElementExtension
            // during a "Paste".
            if (sourceElement is DslModeling::ExtensionElement &&
                sourceElement.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo.ContainsKey("{9DAFD42A-DC0E-4d78-8C3F-8266B2CF8B33}"))
            {
                return;
            }

            // Fall through to base class if this class hasn't handled the merge.
            base.MergeRelate(sourceElement, elementGroup);
        }
        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::Company.DoubleClickOnShape.ExampleElement)
                {
                    if (candidateTarget is global::Company.DoubleClickOnShape.ExampleElement)
                    {
                        global::Company.DoubleClickOnShape.ExampleElement sourceExampleElement = (global::Company.DoubleClickOnShape.ExampleElement)candidateSource;
                        global::Company.DoubleClickOnShape.ExampleElement targetExampleElement = (global::Company.DoubleClickOnShape.ExampleElement)candidateTarget;
                        if (targetExampleElement == null || sourceExampleElement == null || global::Company.DoubleClickOnShape.ExampleElementReferencesTargets.GetLinks(sourceExampleElement, targetExampleElement).Count > 0)
                        {
                            return(false);
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #4
0
        protected override void MergeDisconnect(DslModeling::ModelElement sourceElement)
        {
            if (sourceElement == null)
            {
                throw new global::System.ArgumentNullException("sourceElement");
            }

            global::Company.DoubleClickOnShape.ExampleElement sourceExampleElement1 = sourceElement as global::Company.DoubleClickOnShape.ExampleElement;
            if (sourceExampleElement1 != null)
            {
                // Delete link for path ExampleModelHasElements.Elements

                foreach (DslModeling::ElementLink link in global::Company.DoubleClickOnShape.ExampleModelHasElements.GetLinks((global::Company.DoubleClickOnShape.ExampleModel) this, sourceExampleElement1))
                {
                    // Delete the link, but without possible delete propagation to the element since it's moving to a new location.
                    link.Delete(global::Company.DoubleClickOnShape.ExampleModelHasElements.ExampleModelDomainRoleId, global::Company.DoubleClickOnShape.ExampleModelHasElements.ElementDomainRoleId);
                }

                return;
            }
            // Fall through to base class if this class hasn't handled the unmerge.
            base.MergeDisconnect(sourceElement);
        }
예제 #5
0
 public static global::Company.DoubleClickOnShape.ExampleElementReferencesTargets GetLink(global::Company.DoubleClickOnShape.ExampleElement source, global::Company.DoubleClickOnShape.ExampleElement target)
 {
     global::System.Collections.Generic.IList <global::Company.DoubleClickOnShape.ExampleElementReferencesTargets> links = DslModeling::DomainRoleInfo.GetElementLinks <global::Company.DoubleClickOnShape.ExampleElementReferencesTargets>(source, global::Company.DoubleClickOnShape.ExampleElementReferencesTargets.SourceDomainRoleId);
     foreach (global::Company.DoubleClickOnShape.ExampleElementReferencesTargets link in links)
     {
         if (target.Equals(link.Target))
         {
             return(link);
         }
     }
     return(null);
 }
예제 #6
0
 public static global::System.Collections.ObjectModel.ReadOnlyCollection <global::Company.DoubleClickOnShape.ExampleElementReferencesTargets> GetLinks(global::Company.DoubleClickOnShape.ExampleElement source, global::Company.DoubleClickOnShape.ExampleElement target)
 {
     global::System.Collections.Generic.List <global::Company.DoubleClickOnShape.ExampleElementReferencesTargets>  outLinks = new global::System.Collections.Generic.List <global::Company.DoubleClickOnShape.ExampleElementReferencesTargets>();
     global::System.Collections.Generic.IList <global::Company.DoubleClickOnShape.ExampleElementReferencesTargets> links    = DslModeling::DomainRoleInfo.GetElementLinks <global::Company.DoubleClickOnShape.ExampleElementReferencesTargets>(source, global::Company.DoubleClickOnShape.ExampleElementReferencesTargets.SourceDomainRoleId);
     foreach (global::Company.DoubleClickOnShape.ExampleElementReferencesTargets link in links)
     {
         if (target.Equals(link.Target))
         {
             outLinks.Add(link);
         }
     }
     return(outLinks.AsReadOnly());
 }
예제 #7
0
 public static global::System.Collections.ObjectModel.ReadOnlyCollection <global::Company.DoubleClickOnShape.ExampleElementReferencesTargets> GetLinksToSources(global::Company.DoubleClickOnShape.ExampleElement targetInstance)
 {
     return(DslModeling::DomainRoleInfo.GetElementLinks <global::Company.DoubleClickOnShape.ExampleElementReferencesTargets>(targetInstance, global::Company.DoubleClickOnShape.ExampleElementReferencesTargets.TargetDomainRoleId));
 }
예제 #8
0
 public static global::Company.DoubleClickOnShape.ExampleModelHasElements GetLinkToExampleModel(global::Company.DoubleClickOnShape.ExampleElement elementInstance)
 {
     global::System.Collections.Generic.IList <global::Company.DoubleClickOnShape.ExampleModelHasElements> links = DslModeling::DomainRoleInfo.GetElementLinks <global::Company.DoubleClickOnShape.ExampleModelHasElements>(elementInstance, global::Company.DoubleClickOnShape.ExampleModelHasElements.ElementDomainRoleId);
     global::System.Diagnostics.Debug.Assert(links.Count <= 1, "Multiplicity of Element not obeyed.");
     if (links.Count == 0)
     {
         return(null);
     }
     else
     {
         return(links[0]);
     }
 }
예제 #9
0
 public static global::Company.DoubleClickOnShape.ExampleModel GetParentForExampleElement(global::Company.DoubleClickOnShape.ExampleElement root)
 {
     // Segments 0 and 1
     global::Company.DoubleClickOnShape.ExampleModel result = root.ExampleModel;
     if (result == null)
     {
         return(null);
     }
     return(result);
 }