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 IEntitySource FillEntitySourceGaps(IEntitySource userSource) { bool isNullSource = (null == this.defaultSource); bool isNullInput = (null == userSource); if (isNullSource && isNullInput) { return(null); } else if (isNullInput) { return(this.defaultSource.ShallowCopy()); } else if (isNullSource) { return(userSource.ShallowCopy()); } string entityNamespace = (null != userSource.EntityNamespace) ? userSource.EntityNamespace : this.defaultSource.EntityNamespace; string entityController = (null != userSource.EntityController) ? userSource.EntityController : this.defaultSource.EntityController; string entityId = (null != userSource.EntityId) ? userSource.EntityId : this.defaultSource.EntityId; string entityAction = (null != userSource.EntityAction) ? userSource.EntityAction : this.defaultSource.EntityAction; return(new EntitySource(entityNamespace, entityController, entityId, entityAction)); }
public EntitySourceMerger(IEntitySource defaultSource) { if (null == defaultSource) { return; } this.defaultSource = defaultSource.ShallowCopy(); }