コード例 #1
0
ファイル: UseParser.cs プロジェクト: ranganathsb/sharpDox
        private void ResolveCall(SDNode call)
        {
            if (call is SDTargetNode)
            {
                var targetNode = call as SDTargetNode;
                var calledType = _sdRepository.GetTypeByIdentifier(targetNode.CalledType.Identifier);
                var callerType = _sdRepository.GetTypeByIdentifier(targetNode.CallerType.Identifier);

                if (calledType != null && callerType != null && calledType.Identifier != callerType.Identifier && !calledType.IsProjectStranger && !callerType.IsProjectStranger)
                {
                    if (!calledType.IsProjectStranger && calledType.UsedBy.SingleOrDefault(u => u.Identifier == callerType.Identifier) == null)
                    {
                        calledType.UsedBy.Add(callerType);
                    }

                    if (!calledType.IsProjectStranger && callerType.Uses.SingleOrDefault(u => u.Identifier == calledType.Identifier) == null)
                    {
                        callerType.Uses.Add(calledType);
                    }

                    var calledNamespace = _sdRepository.GetNamespaceByIdentifier(calledType.Namespace.Identifier);
                    var callerNamespace = _sdRepository.GetNamespaceByIdentifier(callerType.Namespace.Identifier);

                    if (calledNamespace != null && callerNamespace != null && calledNamespace.Fullname != callerNamespace.Fullname)
                    {
                        if (calledNamespace.UsedBy.SingleOrDefault(u => u.Fullname == callerNamespace.Fullname) == null)
                        {
                            calledNamespace.UsedBy.Add(callerNamespace);
                        }

                        if (callerNamespace.Uses.SingleOrDefault(u => u.Fullname == calledNamespace.Fullname) == null)
                        {
                            callerNamespace.Uses.Add(calledNamespace);
                        }
                    }
                }
            }
            else if (call is SDBlock)
            {
                foreach (var embeddedCall in ((SDBlock)call).Statements)
                {
                    ResolveCall(embeddedCall);
                }
            }
            else if (call is SDConditionalBlock)
            {
                foreach (var embeddedCall in ((SDConditionalBlock)call).TrueStatements)
                {
                    ResolveCall(embeddedCall);
                }
                foreach (var embeddedCall in ((SDConditionalBlock)call).FalseStatements)
                {
                    ResolveCall(embeddedCall);
                }
            }
        }
コード例 #2
0
        private bool NodeNotEmpty(SDNode node, List <SDNode> calls)
        {
            var targetNode = node as SDTargetNode;

            if (targetNode != null)
            {
                if (!targetNode.CalledType.IsProjectStranger)
                {
                    return(true);
                }
            }

            if (calls != null)
            {
                if (calls.Count == 0)
                {
                    return(false);
                }

                var empty = false;

                foreach (var call in calls)
                {
                    var block = call as SDBlock;
                    if (block != null && NodeNotEmpty(block, block.Statements))
                    {
                        empty = true;
                        break;
                    }

                    var conditionalBlock = call as SDConditionalBlock;
                    if (conditionalBlock != null && NodeNotEmpty(conditionalBlock, conditionalBlock.TrueStatements))
                    {
                        empty = true;
                        break;
                    }

                    var target = call as SDTargetNode;
                    if (target != null && NodeNotEmpty(target, null))
                    {
                        empty = true;
                        break;
                    }
                }

                return(empty);
            }

            return(false);
        }
コード例 #3
0
ファイル: UseParser.cs プロジェクト: JoeHosman/sharpDox
        private void ResolveCall(SDNode call)
		{
			if (call is SDTargetNode)
			{
				var targetNode = call as SDTargetNode;
                var calledType = _repository.GetTypeByIdentifier(targetNode.CalledType.Identifier);
                var callerType = _repository.GetTypeByIdentifier(targetNode.CallerType.Identifier);

                if (calledType != null && callerType != null && calledType.Identifier != callerType.Identifier)
				{
                    if (!calledType.IsProjectStranger && calledType.UsedBy.SingleOrDefault(u => u.Identifier == callerType.Identifier) == null)
                        calledType.UsedBy.Add(callerType);

                    if (!calledType.IsProjectStranger && callerType.Uses.SingleOrDefault(u => u.Identifier == calledType.Identifier) == null)
                        callerType.Uses.Add(calledType);

                    var calledNamespace = _repository.GetNamespaceByIdentifier(calledType.Namespace.Identifier);
                    var callerNamespace = _repository.GetNamespaceByIdentifier(callerType.Namespace.Identifier);

					if (calledNamespace != null && callerNamespace != null && calledNamespace.Fullname != callerNamespace.Fullname)
					{
                        if (calledNamespace.UsedBy.SingleOrDefault(u => u.Fullname == callerNamespace.Fullname) == null)
							calledNamespace.UsedBy.Add(callerNamespace);

                        if (callerNamespace.Uses.SingleOrDefault(u => u.Fullname == calledNamespace.Fullname) == null)
                            callerNamespace.Uses.Add(calledNamespace);
					}
				}
			}
			else if (call is SDBlock)
			{
				foreach(var embeddedCall in ((SDBlock)call).Statements)
				{
                    ResolveCall(embeddedCall);
				}
			}
            else if (call is SDConditionalBlock)
            {
                foreach (var embeddedCall in ((SDConditionalBlock)call).TrueStatements)
                {
                    ResolveCall(embeddedCall);
                }
                foreach (var embeddedCall in ((SDConditionalBlock)call).FalseStatements)
                {
                    ResolveCall(embeddedCall);
                }
            }
		}
コード例 #4
0
        private bool NodeNotEmpty(SDNode node, List<SDNode> calls)
        {
            var targetNode = node as SDTargetNode;
            if (targetNode != null)
            {
                if (!targetNode.CalledType.IsProjectStranger)
                {
                    return true;
                }
            }

            if (calls != null)
            {
                if (calls.Count == 0)
                    return false;

                var empty = false;

                foreach (var call in calls)
                {
                    var block = call as SDBlock;
                    if (block != null && NodeNotEmpty(block, block.Statements))
                    {
                        empty = true;
                        break;
                    }

                    var conditionalBlock = call as SDConditionalBlock;
                    if (conditionalBlock != null && NodeNotEmpty(conditionalBlock, conditionalBlock.TrueStatements))
                    {
                        empty = true;
                        break;
                    }

                    var target = call as SDTargetNode;
                    if (target != null && NodeNotEmpty(target, null))
                    {
                        empty = true;
                        break;
                    }
                }

                return empty;
            }

            return false;
        }
コード例 #5
0
        private void ParseCall(SDNode call, SequenceDiagramComposite composite)
        {
            var block = call as SDBlock;
            if (block != null && NodeNotEmpty(block, block.Statements))
            {
                ParseMethodBlock(composite, block);
            }

            var conditionalBlock = call as SDConditionalBlock;
            if (conditionalBlock != null && NodeNotEmpty(conditionalBlock, conditionalBlock.TrueStatements))
            {
                ParseConditionalMethodBlock(composite, conditionalBlock);
            }

            var targetNode = call as SDTargetNode;
            if (targetNode != null && NodeNotEmpty(targetNode, null))
            {
                ParseTargetNode(composite, targetNode);
            }
        }
コード例 #6
0
        private void ParseCall(SDNode call, SequenceDiagramComposite composite)
        {
            var block = call as SDBlock;

            if (block != null && NodeNotEmpty(block, block.Statements))
            {
                ParseMethodBlock(composite, block);
            }

            var conditionalBlock = call as SDConditionalBlock;

            if (conditionalBlock != null && NodeNotEmpty(conditionalBlock, conditionalBlock.TrueStatements))
            {
                ParseConditionalMethodBlock(composite, conditionalBlock);
            }

            var targetNode = call as SDTargetNode;

            if (targetNode != null && NodeNotEmpty(targetNode, null))
            {
                ParseTargetNode(composite, targetNode);
            }
        }