private Expression CreateScalarPropertiesAsFormEncodedStringMethod(TypeDefinitionExpression expression)
        {
            var self       = Expression.Parameter(expression.Type, "self");
            var properties = ExpressionGatherer.Gather(expression, ServiceExpressionType.PropertyDefinition).Where(c => !(c.Type is FickleListType)).ToList();
            var parameters = properties.OfType <PropertyDefinitionExpression>().ToDictionary(c => c.PropertyName, c => Expression.Property(self, c.PropertyName));
            var path       = string.Join("", properties.OfType <PropertyDefinitionExpression>().Select(c => c.PropertyName + "={" + c.PropertyName + "}"));

            var formatInfo = ObjectiveStringFormatInfo.GetObjectiveStringFormatInfo
                             (
                path,
                c => parameters[c],
                (s, t) => t == typeof(string) ? s : s + "&",
                c => FickleExpression.Call(c, typeof(string), "stringByAppendingString", Expression.Constant("&"))
                             );

            var parameterInfos = new List <ParameterInfo>
            {
                new FickleParameterInfo(typeof(string), "format")
            };

            parameterInfos.AddRange(formatInfo.ParameterExpressions.Select(c => new ObjectiveParameterInfo(c.Type, c.Name, true)));

            var args = new List <Expression>
            {
                Expression.Constant(formatInfo.Format)
            };

            args.AddRange(formatInfo.ValueExpressions);

            var methodInfo = new FickleMethodInfo(typeof(string), typeof(string), "stringWithFormat", parameterInfos.ToArray(), true);
            var methodBody = Expression.Block(FickleExpression.Return(Expression.Call(null, methodInfo, args)).ToStatement());

            return(new MethodDefinitionExpression("scalarPropertiesAsFormEncodedString", new List <Expression>().ToReadOnlyCollection(), typeof(string), methodBody, false, null));
        }
        protected override void GenerateGateway(CodeGenerationContext codeGenerationContext, TypeDefinitionExpression expression)
        {
            List <Expression> methods;

            using (var writer = this.GetTextWriterForFile(expression.Type.Name + ".m"))
            {
                var classFileExpression = GatewaySourceExpressionBinder.Bind(codeGenerationContext, expression);

                var codeGenerator = new ObjectiveCodeGenerator(writer);

                methods = ExpressionGatherer.Gather(classFileExpression, ServiceExpressionType.MethodDefinition);

                codeGenerator.Generate(classFileExpression);
            }

            using (var writer = this.GetTextWriterForFile(expression.Type.Name + ".h"))
            {
                var headerFileExpression = GatewayHeaderExpressionBinder.Bind(codeGenerationContext, expression, methods.Cast <MethodDefinitionExpression>().ToList());

                var codeGenerator = new ObjectiveCodeGenerator(writer);

                codeGenerator.Generate(headerFileExpression);
            }
        }