static IUnresolvedTypeDefinition CreateClass(Project project, Stetic.ActionGroupComponent group, string name, string namspace, string folder)
        {
            string fullName = namspace.Length > 0 ? namspace + "." + name : name;

            var type = new CodeTypeDeclaration();

            type.Name    = name;
            type.IsClass = true;
            type.BaseTypes.Add(new CodeTypeReference("Gtk.ActionGroup"));

            // Generate the constructor. It contains the call that builds the widget.

            var ctor = new CodeConstructor();

            ctor.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            ctor.BaseConstructorArgs.Add(new CodePrimitiveExpression(fullName));

            var call = new CodeMethodInvokeExpression(
                new CodeMethodReferenceExpression(
                    new CodeTypeReferenceExpression("Stetic.Gui"),
                    "Build"
                    ),
                new CodeThisReferenceExpression(),
                new CodeTypeOfExpression(fullName)
                );

            ctor.Statements.Add(call);
            type.Members.Add(ctor);

            // Add signal handlers
            foreach (Stetic.ActionComponent action in group.GetActions())
            {
                foreach (Stetic.Signal signal in action.GetSignals())
                {
                    CodeMemberMethod met = new CodeMemberMethod();
                    met.Name       = signal.Handler;
                    met.Attributes = MemberAttributes.Family;
                    met.ReturnType = new CodeTypeReference(signal.SignalDescriptor.HandlerReturnTypeName);

                    foreach (Stetic.ParameterDescriptor pinfo in signal.SignalDescriptor.HandlerParameters)
                    {
                        met.Parameters.Add(new CodeParameterDeclarationExpression(pinfo.TypeName, pinfo.Name));
                    }

                    type.Members.Add(met);
                }
            }

            // Create the class
            return(CodeGenerationService.AddType((DotNetProject)project, folder, namspace, type));
        }
        static ITypeSymbol CreateClass(MonoDevelop.Projects.Project project, Stetic.ActionGroupComponent group, string name, string namspace, string folder)
        {
            string fullName = namspace.Length > 0 ? namspace + "." + name : name;

            var type = SyntaxFactory.ClassDeclaration(name)
                       .AddBaseListTypes(SyntaxFactory.SimpleBaseType(SyntaxFactory.ParseTypeName("Gtk.ActionGroup")));

            // Generate the constructor. It contains the call that builds the widget.
            var members = new SyntaxList <MemberDeclarationSyntax> ();

            var ctor = SyntaxFactory.ConstructorDeclaration(
                new SyntaxList <AttributeListSyntax> (),
                SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword)),
                SyntaxFactory.Identifier(name),
                SyntaxFactory.ParameterList(),
                SyntaxFactory.ConstructorInitializer(SyntaxKind.BaseKeyword, SyntaxFactory.ArgumentList(new SeparatedSyntaxList <ArgumentSyntax> {
                SyntaxFactory.Argument(SyntaxFactory.ParseExpression(fullName))
            })),
                SyntaxFactory.Block(
                    SyntaxFactory.ExpressionStatement(
                        SyntaxFactory.InvocationExpression(
                            SyntaxFactory.ParseExpression("Stetic.Gui.Build"),
                            SyntaxFactory.ArgumentList(
                                new SeparatedSyntaxList <ArgumentSyntax> {
                SyntaxFactory.Argument(SyntaxFactory.ThisExpression()),
                SyntaxFactory.Argument(SyntaxFactory.ParseExpression(fullName))
            }
                                )
                            )
                        )
                    )
                );

            type = type.AddMembers(ctor);

            // Add signal handlers
            foreach (Stetic.ActionComponent action in group.GetActions())
            {
                foreach (Stetic.Signal signal in action.GetSignals())
                {
                    var parameters = new SeparatedSyntaxList <ParameterSyntax> ();
                    foreach (var p in signal.SignalDescriptor.HandlerParameters)
                    {
                        parameters = parameters.Add(SyntaxFactory.Parameter(new SyntaxList <AttributeListSyntax> (), SyntaxFactory.TokenList(), SyntaxFactory.ParseTypeName(p.TypeName), SyntaxFactory.Identifier(p.Name), null));
                    }

                    var met = SyntaxFactory.MethodDeclaration(
                        new SyntaxList <AttributeListSyntax> (),
                        SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.ProtectedKeyword)),
                        SyntaxFactory.ParseTypeName(signal.SignalDescriptor.HandlerReturnTypeName),
                        null,
                        SyntaxFactory.Identifier(signal.Handler),
                        null,
                        SyntaxFactory.ParameterList(parameters),
                        new SyntaxList <TypeParameterConstraintClauseSyntax> (),
                        SyntaxFactory.Block(),
                        null
                        );


                    type = type.AddMembers(met);
                }
            }

            // Create the class
            return(CodeGenerationService.AddType((DotNetProject)project, folder, namspace, type));
        }