public override object VisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data)
        {
            if (usings != null && !usings.ContainsKey("System.Runtime.InteropServices"))
            {
                UsingDeclaration @using = new UsingDeclaration("System.Runtime.InteropServices");
                addedUsings.Add(@using);
                base.VisitUsingDeclaration(@using, data);
            }

            MethodDeclaration method = new MethodDeclaration(declareDeclaration.Name, declareDeclaration.Modifier,
                                                             declareDeclaration.TypeReference, declareDeclaration.Parameters,
                                                             declareDeclaration.Attributes);

            if ((method.Modifier & Modifiers.Visibility) == 0)
            {
                method.Modifier |= Modifiers.Public;
            }
            method.Modifier |= Modifiers.Extern | Modifiers.Static;

            if (method.TypeReference.IsNull)
            {
                method.TypeReference = new TypeReference("System.Void");
            }

            Attribute att = new Attribute("DllImport", null, null);

            att.PositionalArguments.Add(CreateStringLiteral(declareDeclaration.Library));
            if (declareDeclaration.Alias.Length > 0)
            {
                att.NamedArguments.Add(new NamedArgumentExpression("EntryPoint", CreateStringLiteral(declareDeclaration.Alias)));
            }
            switch (declareDeclaration.Charset)
            {
            case CharsetModifier.Auto:
                att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
                                                                   new FieldReferenceExpression(new IdentifierExpression("CharSet"),
                                                                                                "Auto")));
                break;

            case CharsetModifier.Unicode:
                att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
                                                                   new FieldReferenceExpression(new IdentifierExpression("CharSet"),
                                                                                                "Unicode")));
                break;

            default:
                att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
                                                                   new FieldReferenceExpression(new IdentifierExpression("CharSet"),
                                                                                                "Ansi")));
                break;
            }
            att.NamedArguments.Add(new NamedArgumentExpression("SetLastError", new PrimitiveExpression(true, true.ToString())));
            att.NamedArguments.Add(new NamedArgumentExpression("ExactSpelling", new PrimitiveExpression(true, true.ToString())));
            AttributeSection sec = new AttributeSection(null, null);

            sec.Attributes.Add(att);
            method.Attributes.Add(sec);
            ReplaceCurrentNode(method);
            return(base.VisitMethodDeclaration(method, data));
        }
 public override object VisitAttribute(AIMS.Libraries.Scripting.NRefactory.Ast.Attribute attribute, object data)
 {
     list[new PossibleTypeReference(attribute.Name)] = data;
     list[new PossibleTypeReference(attribute.Name + "Attribute")] = data;
     return(base.VisitAttribute(attribute, data));
 }