public ScApiSession( ISessionConfig config, IEntitySource entitySource, IScCredentials credentials, IMediaLibrarySettings mediaSettings, ItemSource defaultSource = null) { if (null == config) { throw new ArgumentNullException("ScApiSession.config cannot be null"); } if (entitySource != null) { this.entitySource = entitySource.ShallowCopy(); } this.sessionConfig = config.SessionConfigShallowCopy(); this.requestMerger = new UserRequestMerger(this.sessionConfig, defaultSource, this.entitySource); if (null != credentials) { this.credentials = credentials.CredentialsShallowCopy(); } if (null != mediaSettings) { this.mediaSettings = mediaSettings.MediaSettingsShallowCopy(); } this.cookies = new CookieContainer(); this.handler = new HttpClientHandler(); this.handler.CookieContainer = cookies; this.httpClient = new HttpClient(this.handler); }
public IBaseSessionBuilder Credentials(IScCredentials credentials) { // @adk : won't be invoked more than once. // No validation needed. BaseValidator.CheckForNullAndEmptyOrThrow(credentials.Username, this.GetType().Name + ".Credentials.Username"); BaseValidator.CheckForNullAndEmptyOrThrow(credentials.Password, this.GetType().Name + ".Credentials.Password"); this.credentials = credentials.CredentialsShallowCopy(); return(this); }