Пример #1
0
        /// <summary>
        /// Creates a new media resource and adds it to the storage
        /// </summary>
        /// <param name="entity">entity instance.</param>
        /// <param name="streamProperty">stream info.</param>
        /// <returns>Returns the newly created media resource instance.</returns>
        public virtual DSPMediaResource CreateMediaResource(object entity, ResourceProperty streamProperty)
        {
            if (this.inMemoryStreamStorage == null)
            {
                this.inMemoryStreamStorage = this.keyComparer == null ? new Dictionary<object, Dictionary<string, DSPMediaResource>>() : new Dictionary<object, Dictionary<string, DSPMediaResource>>(this.keyComparer);
            }

            Dictionary<string, DSPMediaResource> streams;
            if (!this.inMemoryStreamStorage.TryGetValue(entity, out streams))
            {
                streams = new Dictionary<string, DSPMediaResource>();
                this.inMemoryStreamStorage[entity] = streams;
            }

            string streamName = streamProperty == null ? string.Empty : streamProperty.Name;
            streams[streamName] = new DSPMediaResource();
            return streams[streamName];
        }
Пример #2
0
        /// <summary>
        /// Creates a new media resource and adds it to the storage
        /// </summary>
        /// <param name="entity">entity instance.</param>
        /// <param name="streamProperty">stream info.</param>
        /// <returns>Returns the newly created media resource instance.</returns>
        public virtual DSPMediaResource CreateMediaResource(object entity, ResourceProperty streamProperty)
        {
            if (this.inMemoryStreamStorage == null)
            {
                this.inMemoryStreamStorage = this.keyComparer == null ? new Dictionary <object, Dictionary <string, DSPMediaResource> >() : new Dictionary <object, Dictionary <string, DSPMediaResource> >(this.keyComparer);
            }

            Dictionary <string, DSPMediaResource> streams;

            if (!this.inMemoryStreamStorage.TryGetValue(entity, out streams))
            {
                streams = new Dictionary <string, DSPMediaResource>();
                this.inMemoryStreamStorage[entity] = streams;
            }

            string streamName = streamProperty == null ? string.Empty : streamProperty.Name;

            streams[streamName] = new DSPMediaResource();
            return(streams[streamName]);
        }
Пример #3
0
        /// <summary>
        /// Gets the specified media resource.
        /// </summary>
        /// <param name="entity">entity instance.</param>
        /// <param name="streamProperty">stream info.</param>
        /// <param name="mediaResource">media resource info.</param>
        /// <returns>true if the specified media resource is found.</returns>
        public virtual bool TryGetMediaResource(object entity, ResourceProperty streamProperty, out DSPMediaResource mediaResource)
        {
            Dictionary <string, DSPMediaResource> streams;

            if (this.inMemoryStreamStorage == null || !this.inMemoryStreamStorage.TryGetValue(entity, out streams))
            {
                mediaResource = null;
                return(false);
            }

            if (!streams.TryGetValue(streamProperty == null ? string.Empty : streamProperty.Name, out mediaResource))
            {
                mediaResource = null;
                return(false);
            }

            return(true);
        }
Пример #4
0
        /// <summary>
        /// Gets the specified media resource.
        /// </summary>
        /// <param name="entity">entity instance.</param>
        /// <param name="streamProperty">stream info.</param>
        /// <param name="mediaResource">media resource info.</param>
        /// <returns>true if the specified media resource is found.</returns>
        public virtual bool TryGetMediaResource(object entity, ResourceProperty streamProperty, out DSPMediaResource mediaResource)
        {
            Dictionary<string, DSPMediaResource> streams;
            if (this.inMemoryStreamStorage == null || !this.inMemoryStreamStorage.TryGetValue(entity, out streams))
            {
                mediaResource = null;
                return false;
            }

            if (!streams.TryGetValue(streamProperty == null ? string.Empty : streamProperty.Name, out mediaResource))
            {
                mediaResource = null;
                return false;
            }

            return true;
        }