/// <summary> /// Get or create a write contract for <paramref name="type"/>. /// </summary> /// <param name="type">The type to get or create a write contract for.</param> /// <returns>The write contract corresponding to <paramref name="type"/>.</returns> public IWriteContract GetOrAddWriteContract(Type type) { if (type == typeof(Empty)) { return(Intern(new EmptyContract())); } if (PrimitiveContract.CanProcess(type)) { return(Intern(new PrimitiveContract(type))); } if (EnumContract.CanProcess(type)) { return(Intern(new EnumContract(type))); } if (TupleWriteContract.CanProcess(type)) { return(Intern(new TupleWriteContract(type, this))); } if (NullableWriteContract.CanProcess(type)) { return(Intern(new NullableWriteContract(type, this))); } if (ListWriteContract.CanProcess(type)) { return(Intern(new ListWriteContract(type, this))); } if (DictionaryWriteContract.CanProcess(type)) { return(Intern(new DictionaryWriteContract(type, this))); } if (UnionWriteContract.CanProcess(type)) { return(Intern(new UnionWriteContract(type, this))); } return(Intern(new ComplexWriteContract(type, this))); }
internal static bool CanProcess(Type type) => ListWriteContract.CanProcess(type);