/// <summary> /// Creates a scalar containing field /// </summary> /// <param name="name">The field name</param> /// <param name="type">The field type</param> /// <param name="flags">The field flags</param> /// <param name="arguments"> /// The arguments (if is set - this field becomes a method) /// </param> /// <param name="description"> /// The field description /// </param> /// <returns>The new field</returns> public static ApiField Scalar( [NotNull] string name, EnScalarType type, EnFieldFlags flags = EnFieldFlags.Queryable, IEnumerable <ApiField> arguments = null, string description = null) { if (type == EnScalarType.None) { throw new ArgumentException("Type cannot be None"); } if (flags.HasFlag(EnFieldFlags.IsConnection)) { throw new ArgumentException("Scalar field can't be used as connected objects"); } return(new ApiField(name, flags) { ScalarType = type, Description = description, Arguments = arguments != null ? new List <ApiField>(arguments) : new List <ApiField>() }); }
/// <summary> /// Creates the scalar type definition /// </summary> /// <param name="scalarType">The type of scalar</param> /// <param name="typesCreated">The list of types created to fill</param> /// <returns>The scalar type</returns> private static MergedType CreateScalarType(EnScalarType scalarType, Dictionary <string, MergedType> typesCreated) { MergedType createdType; var mergedScalarType = new MergedScalarType(scalarType); if (typesCreated.TryGetValue(mergedScalarType.ComplexTypeName, out createdType)) { return(createdType); } typesCreated[mergedScalarType.ComplexTypeName] = mergedScalarType; return(mergedScalarType); }
/// <inheritdoc /> public MergedScalarType(EnScalarType type) : base(type.ToString()) { this.ScalarType = type; }