private void AddContract(Type type)
{
if (type == null) throw new ArgumentNullException("type");
if (IsContractRegistered(type))
throw new InvalidOperationException("Type already registered.");
if (!IsValidDataContract(type))
throw new InvalidDataContractException(string.Format("Type '{0}' is not a valid data contract.", type.FullName));
_contracts.Add(type);
if (type.IsClass)
{
var memberTypes = ProcessClass(type);
foreach (var subtype in memberTypes)
{
if (IsContractRegistered(subtype) || !IsValidDataContract(subtype)) continue;
AddContract(subtype);
}
}
}