示例#1
0
        public Document(BaseMedia media)
            : this()
        {
            if (media == null)
            {
                throw new ArgumentNullException("media");
            }

            this.Copy(media);
            this.RawData = media.RawData;
        }
示例#2
0
        public BaseMedia Save(BaseMedia media)
        {
            #region argument checking

            if (media == null)
            {
                throw new ArgumentNullException("media");
            }

            if (string.IsNullOrEmpty(media.Url))
            {
                throw new ArgumentNullException("media.Url");
            }

            if (string.IsNullOrEmpty(media.Name))
            {
                throw new ArgumentNullException("media.Name");
            }

            if (media.Owner == null)
            {
                throw new InvalidOperationException("media.Owner");
            }

            #endregion

            return MediaDbInteractor.Instance.SaveMedia(media.Owner.Id, media.MediaType, media.Name, media.Url, media.RawData ?? string.Empty);
        }
示例#3
0
        public bool TryGetMedia(string url, out BaseMedia media)
        {
            media = null;
            bool success = false;

            try
            {
                media = GetMedia(SanitizeUrlKey(url));
                success = true;
            }
            catch (MessageException)
            {
            }

            return success;
        }
示例#4
0
        public void Copy(BaseMedia media)
        {
            if (media == null)
            {
                throw new ArgumentNullException("media");
            }

            this.Id = media.Id;
            this.MediaType = media.MediaType;
            this.Name = media.Name;
            this.Description = media.Description;
            this.Owner = media.Owner;
            this.Url = media.Url;

            this.InitializeTags(media.Tags);
        }