コード例 #1
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::EPAM.NHModelingLanguage.Entity sourceEntity1 = sourceElement as global::EPAM.NHModelingLanguage.Entity;
            if (sourceEntity1 != null)
            {
                // Create link for path NHModelHasEntities.Entities
                this.Entities.Add(sourceEntity1);

                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);
        }
コード例 #2
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::EPAM.NHModelingLanguage.Entity)
                {
                    if (target is global::EPAM.NHModelingLanguage.Entity)
                    {
                        global::EPAM.NHModelingLanguage.Entity sourceAccepted = (global::EPAM.NHModelingLanguage.Entity)source;
                        global::EPAM.NHModelingLanguage.Entity targetAccepted = (global::EPAM.NHModelingLanguage.Entity)target;
                        DslModeling::ElementLink result = new global::EPAM.NHModelingLanguage.EntityInheritedParent(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();
        }
コード例 #3
0
        internal static global::System.Collections.IList GetElementsFromEntityForProperties(DslModeling::ModelElement rootElement)
        {
            global::EPAM.NHModelingLanguage.Entity root = (global::EPAM.NHModelingLanguage.Entity)rootElement;
            // Segments 0 and 1
            DslModeling::LinkedElementCollection <global::EPAM.NHModelingLanguage.Property> result = root.Properties;

            return(result);
        }
コード例 #4
0
 internal static global::System.Collections.ICollection GetEntityForEntityShapeProperties(global::EPAM.NHModelingLanguage.Property root)
 {
     // Segments 1 and 0
     global::EPAM.NHModelingLanguage.Entity result = root.Entity;
     if (result == null)
     {
         return(new DslModeling::ModelElement[0]);
     }
     return(new DslModeling::ModelElement[] { result });
 }
コード例 #5
0
 public static global::EPAM.NHModelingLanguage.NHModel GetParentForEntity(global::EPAM.NHModelingLanguage.Entity root)
 {
     // Segments 0 and 1
     global::EPAM.NHModelingLanguage.NHModel result = root.NHModel;
     if (result == null)
     {
         return(null);
     }
     return(result);
 }
コード例 #6
0
 public static global::EPAM.NHModelingLanguage.EntityInheritedParent GetLink(global::EPAM.NHModelingLanguage.Entity source, global::EPAM.NHModelingLanguage.Entity target)
 {
     global::System.Collections.Generic.IList <global::EPAM.NHModelingLanguage.EntityInheritedParent> links = DslModeling::DomainRoleInfo.GetElementLinks <global::EPAM.NHModelingLanguage.EntityInheritedParent>(source, global::EPAM.NHModelingLanguage.EntityInheritedParent.SourceEntityDomainRoleId);
     foreach (global::EPAM.NHModelingLanguage.EntityInheritedParent link in links)
     {
         if (target.Equals(link.TargetEntity))
         {
             return(link);
         }
     }
     return(null);
 }
コード例 #7
0
 public static global::EPAM.NHModelingLanguage.EntityHasProperties GetLink(global::EPAM.NHModelingLanguage.Entity source, global::EPAM.NHModelingLanguage.Property target)
 {
     global::System.Collections.Generic.IList <global::EPAM.NHModelingLanguage.EntityHasProperties> links = DslModeling::DomainRoleInfo.GetElementLinks <global::EPAM.NHModelingLanguage.EntityHasProperties>(source, global::EPAM.NHModelingLanguage.EntityHasProperties.EntityDomainRoleId);
     foreach (global::EPAM.NHModelingLanguage.EntityHasProperties link in links)
     {
         if (target.Equals(link.Property))
         {
             return(link);
         }
     }
     return(null);
 }
コード例 #8
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::EPAM.NHModelingLanguage.Entity)
                {
                    if (candidateTarget is global::EPAM.NHModelingLanguage.Entity)
                    {
                        global::EPAM.NHModelingLanguage.Entity sourceEntity = (global::EPAM.NHModelingLanguage.Entity)candidateSource;
                        global::EPAM.NHModelingLanguage.Entity targetEntity = (global::EPAM.NHModelingLanguage.Entity)candidateTarget;
                        if (sourceEntity == null || global::EPAM.NHModelingLanguage.EntityInheritedParent.GetLinkToParent(sourceEntity) != null)
                        {
                            return(false);
                        }
                        if (targetEntity == null || sourceEntity == null || global::EPAM.NHModelingLanguage.EntityInheritedParent.GetLinks(sourceEntity, targetEntity).Count > 0)
                        {
                            return(false);
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #9
0
        protected override void MergeDisconnect(DslModeling::ModelElement sourceElement)
        {
            if (sourceElement == null)
            {
                throw new global::System.ArgumentNullException("sourceElement");
            }

            global::EPAM.NHModelingLanguage.Entity sourceEntity1 = sourceElement as global::EPAM.NHModelingLanguage.Entity;
            if (sourceEntity1 != null)
            {
                // Delete link for path NHModelHasEntities.Entities

                foreach (DslModeling::ElementLink link in global::EPAM.NHModelingLanguage.NHModelHasEntities.GetLinks((global::EPAM.NHModelingLanguage.NHModel) this, sourceEntity1))
                {
                    // Delete the link, but without possible delete propagation to the element since it's moving to a new location.
                    link.Delete(global::EPAM.NHModelingLanguage.NHModelHasEntities.NHModelDomainRoleId, global::EPAM.NHModelingLanguage.NHModelHasEntities.EntityDomainRoleId);
                }

                return;
            }
            // Fall through to base class if this class hasn't handled the unmerge.
            base.MergeDisconnect(sourceElement);
        }
コード例 #10
0
 public static global::System.Collections.ObjectModel.ReadOnlyCollection <global::EPAM.NHModelingLanguage.EntityInheritedParent> GetLinks(global::EPAM.NHModelingLanguage.Entity source, global::EPAM.NHModelingLanguage.Entity target)
 {
     global::System.Collections.Generic.List <global::EPAM.NHModelingLanguage.EntityInheritedParent>  outLinks = new global::System.Collections.Generic.List <global::EPAM.NHModelingLanguage.EntityInheritedParent>();
     global::System.Collections.Generic.IList <global::EPAM.NHModelingLanguage.EntityInheritedParent> links    = DslModeling::DomainRoleInfo.GetElementLinks <global::EPAM.NHModelingLanguage.EntityInheritedParent>(source, global::EPAM.NHModelingLanguage.EntityInheritedParent.SourceEntityDomainRoleId);
     foreach (global::EPAM.NHModelingLanguage.EntityInheritedParent link in links)
     {
         if (target.Equals(link.TargetEntity))
         {
             outLinks.Add(link);
         }
     }
     return(outLinks.AsReadOnly());
 }
コード例 #11
0
 public static global::System.Collections.ObjectModel.ReadOnlyCollection <global::EPAM.NHModelingLanguage.EntityInheritedParent> GetLinksToChildren(global::EPAM.NHModelingLanguage.Entity targetEntityInstance)
 {
     return(DslModeling::DomainRoleInfo.GetElementLinks <global::EPAM.NHModelingLanguage.EntityInheritedParent>(targetEntityInstance, global::EPAM.NHModelingLanguage.EntityInheritedParent.TargetEntityDomainRoleId));
 }
コード例 #12
0
 public static global::EPAM.NHModelingLanguage.EntityInheritedParent GetLinkToParent(global::EPAM.NHModelingLanguage.Entity sourceEntityInstance)
 {
     global::System.Collections.Generic.IList <global::EPAM.NHModelingLanguage.EntityInheritedParent> links = DslModeling::DomainRoleInfo.GetElementLinks <global::EPAM.NHModelingLanguage.EntityInheritedParent>(sourceEntityInstance, global::EPAM.NHModelingLanguage.EntityInheritedParent.SourceEntityDomainRoleId);
     global::System.Diagnostics.Debug.Assert(links.Count <= 1, "Multiplicity of SourceEntity not obeyed.");
     if (links.Count == 0)
     {
         return(null);
     }
     else
     {
         return(links[0]);
     }
 }
コード例 #13
0
 public static global::System.Collections.ObjectModel.ReadOnlyCollection <global::EPAM.NHModelingLanguage.EntityHasProperties> GetLinksToProperties(global::EPAM.NHModelingLanguage.Entity entityInstance)
 {
     return(DslModeling::DomainRoleInfo.GetElementLinks <global::EPAM.NHModelingLanguage.EntityHasProperties>(entityInstance, global::EPAM.NHModelingLanguage.EntityHasProperties.EntityDomainRoleId));
 }
コード例 #14
0
 public static global::EPAM.NHModelingLanguage.NHModelHasEntities GetLinkToNHModel(global::EPAM.NHModelingLanguage.Entity entityInstance)
 {
     global::System.Collections.Generic.IList <global::EPAM.NHModelingLanguage.NHModelHasEntities> links = DslModeling::DomainRoleInfo.GetElementLinks <global::EPAM.NHModelingLanguage.NHModelHasEntities>(entityInstance, global::EPAM.NHModelingLanguage.NHModelHasEntities.EntityDomainRoleId);
     global::System.Diagnostics.Debug.Assert(links.Count <= 1, "Multiplicity of Entity not obeyed.");
     if (links.Count == 0)
     {
         return(null);
     }
     else
     {
         return(links[0]);
     }
 }