/// <summary>
        /// Creates class that is used in the <c>where</c> clause.
        /// </summary>
        private ClassDeclarationSyntax GenerateWhere(IEnumerable <Parameter> parameters)
        {
            var propertyDeclarations =
                parameters.Select(p => GenerateProperty(p.Name, p.Type, multi: p.Multi, description: p.Description));

            return(SyntaxEx.ClassDeclaration(m_whereClassName, propertyDeclarations)
                   .AddPrivateConstructor());
        }
        /// <summary>
        /// Creates a class for a set of properties.
        /// </summary>
        protected ClassDeclarationSyntax GenerateClassForProperties(string className, IEnumerable <Property> properties, string baseType = null)
        {
            var propertiesArray = properties.ToArray();

            return(SyntaxEx.ClassDeclaration(
                       className, baseType == null ? null : SyntaxFactory.ParseTypeName(baseType),
                       propertiesArray.Select(p => GenerateProperty(p.Name, p.Type, p.Nullable)))
                   .AddPrivateConstructor()
                   .AddMembers(
                       GenerateParseMethod(className, propertiesArray), GenerateToStringMethod(propertiesArray)));
        }
        /// <summary>
        /// Creates class that is ised in the <c>orderby</c> clause.
        /// Returns <c>null</c>, if the module doesn't support sorting.
        /// </summary>
        private ClassDeclarationSyntax GenerateOrderBy(IEnumerable <Parameter> parameters, IEnumerable <Property> properties)
        {
            var propertyTypes = properties.Distinct().ToDictionary(p => p.Name, p => p.Type);

            var sortParameter = parameters.SingleOrDefault(p => p.Name == "sort");

            if (!parameters.Any(p => p.Name == "dir"))
            {
                return(null);
            }

            IEnumerable <PropertyDeclarationSyntax> propertyDeclarations = null;

            if (sortParameter != null)
            {
                propertyDeclarations =
                    ((EnumParameterType)sortParameter.Type).Values.Select(v => GenerateProperty(v, propertyTypes[v]));
            }

            return(SyntaxEx.ClassDeclaration(m_orderByClassName, propertyDeclarations)
                   .AddPrivateConstructor());
        }