See More

using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace JSONAPI.Core { public interface IModelManager { IPluralizationService PluralizationService { get; } ///

/// Returns the property that is treated as the unique identifier in a given class. /// This is used most importantly by JsonApiFormatter to determine what value to /// write when serializing a "Many" relationship as an array of Ids. It is also /// used to make dummy related objects (with only the Id property set) when /// deserializing a JSON payload that specifies a related object only by Id. /// /// Rules for determining this may vary by implementation. /// /// /// The property determined to represent the Id. PropertyInfo GetIdProperty(Type type); /// /// Returns the key that will be used to represent a collection of objects of a /// given type, for example in the top-level of a JSON API document or within /// the "linked" objects section of a payload. /// /// The serializable Type /// The string denoting the given type in JSON documents. string GetJsonKeyForType(Type type); /// /// Returns the key that will be used to represent the given property in serialized /// JSON. Inverse of GetPropertyForJsonKey. /// /// The serializable property /// The string denoting the given property within a JSON document. string GetJsonKeyForProperty(PropertyInfo propInfo); //TODO: Do we need to have a type parameter here, in case the property is inherited? /// /// Returns the property corresponding to a given JSON Key. Inverse of GetJsonKeyForProperty. /// /// The Type to find the property on /// The JSON key representing a property /// PropertyInfo GetPropertyForJsonKey(Type type, string jsonKey); /// /// Analogue to System.Type.GetProperties(), but made available so that any caching done /// by an IModelManager can be leveraged to return the results faster. /// /// The type to get properties from /// All properties recognized by the IModelManager. //TODO: This needs to include JsonIgnore'd properties, so that they can be found and explicitly included at runtime...confusing? Add another method that excludes these? PropertyInfo[] GetProperties(Type type); /// /// Determines whether or not the given type will be treated as a "Many" relationship. /// /// The serializable Type /// True for Array and IEnumerable<T> types, false otherwise. bool IsSerializedAsMany(Type type); /// /// Analogue for System.Type.GetElementType, but works for arrays or IEnumerable<T>, /// and provides a capture point to cache potentially expensive reflection operations that /// have to occur repeatedly in JsonApiFormatter. /// /// A type which must be either an Array type or implement IEnumerable<T>. /// The element type of an Array, or the first generic parameter of an IEnumerable<T>. Type GetElementType(Type manyType); } }