Beispiel #1
0
        /// <summary>
        /// Creates a data service context.
        /// </summary>
        /// <returns>The new DataServiceContext instance.</returns>
        public override IMediaDataServiceContext CreateDataServiceContext()
        {
            DataServiceContext dataContext = new DataServiceContext(_azureMediaServicesEndpoint, DataServiceProtocolVersion.V3)
            {
                IgnoreMissingProperties         = true,
                IgnoreResourceNotFoundException = true,
                MergeOption = MergeOption.PreserveChanges,
            };

            var clientRequestIdAdapter = new ClientRequestIdAdapter();

            this._dataServiceAdapter.Adapt(dataContext);
            this._serviceVersionAdapter.Adapt(dataContext);
            this._userAgentAdapter.Adapt(dataContext);
            clientRequestIdAdapter.Adapt(dataContext);

            dataContext.ReadingEntity += this.OnReadingEntity;
            var queryRetryPolicy = GetQueryRetryPolicy(null);
            var context          = new MediaDataServiceContext(dataContext, queryRetryPolicy, clientRequestIdAdapter);

            queryRetryPolicy.RetryPolicyAdapter = context;
            return(context);
        }
Beispiel #2
0
        /// <summary>
        /// Creates instance of <see cref="IMediaDataServiceContext"/> with contains additional applyed <see cref="IDataServiceContextAdapter"/> adapters
        /// </summary>
        /// <param name="adapters"></param>
        /// <returns><see cref="IMediaDataServiceContext"/></returns>
        public override IMediaDataServiceContext CreateDataServiceContext(IEnumerable <IDataServiceContextAdapter> adapters)
        {
            DataServiceContext dataContext = new DataServiceContext(_azureMediaServicesEndpoint, DataServiceProtocolVersion.V3)
            {
                IgnoreMissingProperties         = true,
                IgnoreResourceNotFoundException = true,
                MergeOption = MergeOption.PreserveChanges,
            };

            List <IDataServiceContextAdapter> dataServiceContextAdapters = GetDefaultDataContextAdapters().ToList();

            dataServiceContextAdapters.AddRange(adapters.ToList());
            dataServiceContextAdapters.ForEach(c => c.Adapt(dataContext));

            ClientRequestIdAdapter clientRequestIdAdapter = dataServiceContextAdapters.FirstOrDefault(c => c is ClientRequestIdAdapter) as ClientRequestIdAdapter;

            dataContext.ReadingEntity += OnReadingEntity;
            var queryRetryPolicy = GetQueryRetryPolicy(null);
            var context          = new MediaDataServiceContext(dataContext, queryRetryPolicy, clientRequestIdAdapter);

            queryRetryPolicy.RetryPolicyAdapter = context;
            return(context);
        }