using System; using System.Collections.Generic; namespace RestEase { #pragma warning disable CS0618 // Type or member is obsolete /// /// Helper which knows how to serialize query parmaeters /// public abstract class RequestQueryParamSerializer : IRequestQueryParamSerializer #pragma warning restore CS0618 // Type or member is obsolete { /// /// Serialize a query parameter whose value is a collection, into a collection of name -> value pairs /// /// /// Most of the time, you will return a single KeyValuePair for each value in the collection, and all will have /// the same key. However this is not required: you can return whatever you want. /// /// Type of the value to serialize /// Name of the query parameter /// Values of the query parmaeter /// Extra info which may be useful to the serializer /// A colletion of name -> value pairs to use as query parameters public virtual IEnumerable> SerializeQueryCollectionParam(string name, IEnumerable values, RequestQueryParamSerializerInfo info) { throw new NotImplementedException($"You must override and implement SerializeQueryCollectionParam(string name, IEnumerable values, RequestQueryParamSerializerInfo info) in {this.GetType().Name}"); } /// /// Serialize a query parameter whose value is scalar (not a collection), into a collection of name -> value pairs /// /// /// Most of the time, you will only return a single KeyValuePair from this method. However, you are given the flexibility, /// to return multiple KeyValuePairs if you wish. Duplicate keys are allowed: they will be serialized as separate query parameters. /// /// Type of the value to serialize /// Name of the query parameter /// Value of the query parameter /// Extra info which may be useful to the serializer /// A colletion of name -> value pairs to use as query parameters public virtual IEnumerable> SerializeQueryParam(string name, T value, RequestQueryParamSerializerInfo info) { throw new NotImplementedException($"You must override and implement SerializeQueryParam(string name, T value, RequestQueryParamSerializerInfo info) in {this.GetType().Name}"); } } }