Esempio n. 1
0
        public static Dictionary <string, List <KeyValuePair <INode, IMethodOrProperty> > > externalMethodsAndProperties(this O2MappedAstData astData, IMethod iMethod)
        {
            var externalMethods = new Dictionary <string, List <KeyValuePair <INode, IMethodOrProperty> > >();

            // add the current method

            externalMethods.add(iMethod.DotNetName, new KeyValuePair <INode, IMethodOrProperty>(astData.methodDeclaration(iMethod), iMethod));

            var iNodesAdded = new List <INode>();

            foreach (var methodCalled in astData.calledINodesReferences(iMethod))
            {
                if (methodCalled is MemberReferenceExpression)
                {
                    var memberRef = (MemberReferenceExpression)methodCalled;
                    {
                        var methodOrProperty = astData.fromMemberReferenceExpressionGetIMethodOrProperty(memberRef);
                        if (methodOrProperty.notNull())
                        {
                            externalMethods.add(methodOrProperty.DotNetName, new KeyValuePair <INode, IMethodOrProperty>(memberRef, methodOrProperty));
                            iNodesAdded.Add(memberRef);
                        }
                        else
                        {
                            externalMethods.add(astData.getTextForINode(memberRef), new KeyValuePair <INode, IMethodOrProperty>(memberRef, null));
                        }
                    }
                }
            }


            foreach (var mapping in astData.calledIMethods_getMappings(iMethod))
            {
                var iMethodMapping = mapping.Key;
                var iNodeMapping   = mapping.Value;
                if (iNodesAdded.Contains(iNodeMapping).isFalse())
                {
                    if (iNodeMapping is ObjectCreateExpression ||
                        ((iNodeMapping is InvocationExpression &&
                          (iNodeMapping as InvocationExpression).TargetObject.notNull() &&
                          iNodesAdded.Contains((iNodeMapping as InvocationExpression).TargetObject).isFalse())))
                    {
                        var nodeText = (iMethodMapping.notNull())
                                                                                                ? iMethodMapping.DotNetName
                                                                                                : astData.getTextForINode(iNodeMapping);
                        externalMethods.add(nodeText, new KeyValuePair <INode, IMethodOrProperty>(iNodeMapping, iMethodMapping));
                    }
                }
            }

            return(externalMethods);
        }