/// <summary> /// Gets a RestRepository for the specified entity. /// </summary> /// <remarks> /// If the entity has a set of required arguments, then they need to be supplied with this /// function here. /// /// E.g.: For the content: /// var contentRepo = context.Repository<Content>(new { AccountId = 5 }); /// /// Note that any required parameters which are mapped to a different HTTP name, will use /// the name in the model, and not the mapped HTTP name. /// /// E.g. the following will result in an exception: /// var contentRepo = context.Repository<Content>(new { accountId = 5 }); /// </remarks> /// <typeparam name="TEntity">The type of entity to get the repository of.</typeparam> /// <param name="args">A list of required arguments for this model.</param> public IRepository <TEntity> Repository <TEntity>(object args = null) where TEntity : class, new() { CreateModels(); RestEntityConfiguration <TEntity> config; try { config = m_modelBuilder.GetConfig <TEntity>(); } catch (Exception ex) { string msg = String.Format("Entity {0} not configured.", typeof(TEntity).FullName); throw new Exception(msg, ex); } args = args ?? new object(); config.ValidateHasNeededKeys(args); return(new RestRepository <TEntity>( GetRetryPolicy(), GetClient(), BaseUri, args, config)); }