Example #1
0
        private void ResetConnectionsLabelHidden(ConnectionElement connection)
        {
            connection.LabelVisible = true;

            if (_HideNonsenceLabels)
            {
                if (connection.ConnectionType != ConnectionType.Composition && connection.ConnectionType != ConnectionType.Aggregation)
                {
                    BlockElement to = _entityTypes.FirstOrDefault(t => t.FullName == connection.To);
                    if (to == null)
                    {
                        to = _enumTypes.FirstOrDefault(t => t.FullName == connection.To);
                    }

                    var hasNonsenceLabel = to.Name == connection.Label;
                    if (hasNonsenceLabel)
                    {
                        connection.LabelVisible = false;
                    }
                }
            }
        }
Example #2
0
        private void ResetConnectionsLabelHidden(ConnectionElement connection)
        {
            connection.LabelVisible = true;

            if (_HideNonsenceLabels)
            {
                if (connection.ConnectionType != ConnectionType.Composition && connection.ConnectionType != ConnectionType.Aggregation)
                {
                    BlockElement to = _entityTypes.FirstOrDefault(t => t.FullName == connection.To);
                    if (to == null) to = _enumTypes.FirstOrDefault(t => t.FullName == connection.To);

                    var hasNonsenceLabel = to.Name == connection.Label;
                    if (hasNonsenceLabel)
                    {
                        connection.LabelVisible = false;
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// 对于文档中刚加入的元素,还没有加入它对应的连接。
        /// 此方法会添加这些连接。
        /// </summary>
        /// <param name="document"></param>
        private static void TryAddConnectionElements(AddToDocumentArgs args)
        {
            var document = args.Docment;

            var docTypeList = document.EntityTypes
                .Select(et => args.AllTypes.First(e => e.FullName == et.FullName))
                .ToArray();

            foreach (var type in docTypeList)
            {
                //添加继承连接线
                var baseType = type.BaseType;
                if (docTypeList.Contains(baseType))
                {
                    var connectionEl = new ConnectionElement(type.FullName, baseType.FullName);
                    connectionEl.ConnectionType = ConnectionType.Inheritance;
                    TryAddConnection(document, connectionEl);
                }

                //添加引用连接线
                foreach (var reference in type.References)
                {
                    switch (reference.ReferenceType)
                    {
                        case ReferenceType.Normal:
                            //如果被引用的实体也在被选择的列表中,则尝试生成相应的连接。
                            if (docTypeList.Contains(reference.RefEntityType))
                            {
                                var connectionEl = new ConnectionElement(type.FullName, reference.RefEntityType.FullName);
                                connectionEl.ConnectionType = reference.Nullable ? ConnectionType.NullableReference : ConnectionType.Reference;
                                connectionEl.Label = reference.EntityProperty ?? reference.IdProperty;
                                TryAddConnection(document, connectionEl);
                            }
                            break;
                        //暂时忽略
                        //case ReferenceType.Parent:
                        //    break;
                        //case ReferenceType.Child:
                        //    break;
                        default:
                            break;
                    }
                }

                //添加组合连接线
                foreach (var child in type.Children)
                {
                    if (docTypeList.Contains(child.ChildEntityType))
                    {
                        var connectionEl = new ConnectionElement(child.ChildEntityType.FullName, type.FullName);
                        connectionEl.ConnectionType = ConnectionType.Composition;
                        connectionEl.Label = child.Name;
                        TryAddConnection(document, connectionEl);
                    }
                }
            }
        }
Example #4
0
        private static void TryAddConnection(ODMLDocument document, ConnectionElement connectionEl)
        {
            //目前,暂时不支持自关联的线。
            if (connectionEl.From == connectionEl.To) return;

            //要判断是否之前已经添加了这个连接,才继续添加连接。
            if (document.Connections.All(c => c.From != connectionEl.From || c.To != connectionEl.To || c.Label != connectionEl.Label))
            {
                document.Connections.Add(connectionEl);
            }
        }
Example #5
0
 public ConnectionProperties(ConnectionElement element)
 {
     _element = element;
 }