Esempio n. 1
0
        /// <summary>
        /// Gets the generated arguments
        /// </summary>
        /// <returns>The list of arguments</returns>
        public static IEnumerable <ApiField> GetArguments()
        {
            if (FilterType.Fields.Count > 2)
            {
                yield return
                    (FilterType.CreateField(
                         "filter",
                         EnFieldFlags.CanBeUsedInInput | EnFieldFlags.Queryable | EnFieldFlags.IsTypeArgument));
            }

            if (SortType.Values.Any())
            {
                const EnFieldFlags SortFlags =
                    EnFieldFlags.CanBeUsedInInput | EnFieldFlags.Queryable | EnFieldFlags.IsTypeArgument
                    | EnFieldFlags.IsArray;
                yield return(ApiField.Object("sort", SortType.TypeName, SortFlags));
            }

            if (NodeMetaData.KeyProperty != null)
            {
                var keyMetadata = TypeMetadata.GenerateTypeMetadata(
                    NodeMetaData.KeyProperty.PropertyType,
                    NodeMetaData.KeyProperty.GetCustomAttribute <PublishToApiAttribute>());
                if (keyMetadata.ScalarType != EnScalarType.None)
                {
                    yield return
                        (ApiField.Scalar(
                             "id",
                             keyMetadata.ScalarType,
                             EnFieldFlags.CanBeUsedInInput | EnFieldFlags.Queryable | EnFieldFlags.IsTypeArgument));
                }
            }

            yield return
                (ApiField.Scalar(
                     "limit",
                     EnScalarType.Integer,
                     EnFieldFlags.CanBeUsedInInput | EnFieldFlags.Queryable | EnFieldFlags.IsTypeArgument));

            yield return
                (ApiField.Scalar(
                     "offset",
                     EnScalarType.Integer,
                     EnFieldFlags.CanBeUsedInInput | EnFieldFlags.Queryable | EnFieldFlags.IsTypeArgument));
        }