• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Models.MediaContent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Kooboo.CMS.Content.Models.MediaContent的典型用法代码示例。如果您正苦于以下问题:C# MediaContent类的具体用法?C# MediaContent怎么用?C# MediaContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MediaContent类属于Kooboo.CMS.Content.Models命名空间,在下文中一共展示了MediaContent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestSimple

        public void TestSimple()
        {
            //var binaryContentProvider = Providers.GetProviderFactory(repository.DBProvider).GetProvider<IContentProvider<BinaryContent>>();

            var binaryContent1 = new MediaContent(repository.Name, binaryFolder.Name);
            binaryContent1.UserKey = "image1";
            binaryContent1.VirtualPath = "~/binary/image1.jpg";
            binaryContent1.ContentFile = new ContentFile()
            {
                Name = "image1.jpg",
                FileName = "image1.jpg",
                Stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5, 6 })
            };
            binaryContentProvider.Add(binaryContent1);

            var binaryContent2 = new MediaContent(repository.Name, binaryFolder.Name);
            binaryContent2.UserKey = "image2";
            binaryContent2.VirtualPath = "~/binary/image2.jpg";
            binaryContent2.ContentFile = new ContentFile()
            {
                Name = "image2.jpg",
                FileName = "image2.jpg",
                Stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5, 6 })
            };
            binaryContentProvider.Add(binaryContent2);

            var query1 = binaryFolder.CreateQuery().WhereEquals("UUID", (string)(binaryContent1.UUID));
            Assert.AreEqual(1, query1.Count());
            var binaryContentItem1 = query1.First();
            Assert.AreEqual(binaryContent1.UUID, binaryContentItem1.UUID);
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:31,代码来源:MediaContentProviderTests.cs


示例2: BlobToMediaContent

        public static MediaContent BlobToMediaContent(this CloudBlob blob, MediaContent mediaContent)
        {
            if (!string.IsNullOrEmpty(blob.Metadata["Published"]))
            {
                mediaContent.Published = bool.Parse(blob.Metadata["Published"]);
            }
            if (!string.IsNullOrEmpty(blob.Metadata["Size"]))
            {
                mediaContent.Size = int.Parse(blob.Metadata["Size"]);
            }
            mediaContent.FileName = blob.Metadata["FileName"];
            mediaContent.UserKey = mediaContent.FileName;
            mediaContent.UUID = mediaContent.FileName;
            mediaContent.UserId = blob.Metadata["UserId"];
            mediaContent.VirtualPath = blob.Uri.ToString();
            if (mediaContent.Metadata == null)
            {
                mediaContent.Metadata = new MediaContentMetadata();
            }

            mediaContent.Metadata.AlternateText = blob.Metadata["AlternateText"];
            mediaContent.Metadata.Description = blob.Metadata["Description"];
            mediaContent.Metadata.Title = blob.Metadata["Title"];
            return mediaContent;
        }
开发者ID:ZhiGuangHuang,项目名称:CMS,代码行数:25,代码来源:MediaBlobHelper.cs


示例3: Update

        public virtual MediaContent Update(Repository repository, MediaFolder mediaFolder, string uuid, string fileName, Stream fileStream,
            string userid, MediaContentMetadata metadata)
        {
            IsAllowExtension(fileName, mediaFolder.AllowedExtensions);


            var binaryContent = mediaFolder.CreateQuery().WhereEquals("UUID", uuid).First();
            var old = new MediaContent(binaryContent);
            binaryContent.UserId = userid;
            binaryContent.UtcLastModificationDate = DateTime.UtcNow;

            binaryContent.FileName = fileName;
            binaryContent.UserKey = fileName;
            binaryContent.UUID = fileName;

            if (fileStream != null)
            {
                binaryContent.ContentFile = new ContentFile()
                {
                    Name = fileName,
                    FileName = fileName,
                    Stream = fileStream
                };
                Provider.SaveContentStream(old, fileStream);
            }

            binaryContent.Metadata = metadata;
            Provider.Update(binaryContent, old);

            return binaryContent;
        }
开发者ID:Godoy,项目名称:CMS,代码行数:31,代码来源:MediaContentManager.cs


示例4: Test1

        public void Test1()
        {
            MediaContent binaryContent1 = new MediaContent();
            binaryContent1.Repository = repository.Name;
            binaryContent1.FolderName = binaryFolder.Name;
            binaryContent1.FileName = "file1.jpg";
            binaryContent1.VirtualPath = "~/file1.jpg";
            Providers.DefaultProviderFactory.GetProvider<IMediaContentProvider>().Add(binaryContent1);

            MediaContent binaryContent2 = new MediaContent();
            binaryContent2.Repository = repository.Name;
            binaryContent2.FolderName = binaryFolder.Name;
            binaryContent2.FileName = "file2.jpg";
            binaryContent2.VirtualPath = "~/file2.jpg";
            Providers.DefaultProviderFactory.GetProvider<IMediaContentProvider>().Add(binaryContent2);

            var query = binaryFolder.CreateQuery().OrderBy("id");

            Assert.AreEqual(2, query.Count());

            Assert.AreEqual("file1.jpg", query.First().FileName);
            Assert.AreEqual("file2.jpg", query.Last().FileName);

            Providers.DefaultProviderFactory.GetProvider<IMediaContentProvider>().Delete(binaryContent1);
            Assert.AreEqual(1, query.Count());
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:26,代码来源:BinaryContentProviderTests.cs


示例5: Add

        public virtual MediaContent Add(Repository repository, MediaFolder mediaFolder, string fileName, Stream fileStream, bool @overrided,
            string userId, MediaContentMetadata metadata)
        {
            fileName = UrlUtility.ToUrlString(Path.GetFileNameWithoutExtension(fileName)) + Path.GetExtension(fileName);
            IsAllowExtension(fileName, mediaFolder.AllowedExtensions);

            var mediaContent = new MediaContent(repository.Name, mediaFolder.FullName);

            mediaContent.UserId = userId;
            mediaContent.Published = true;

            mediaContent.FileName = fileName;

            mediaContent.UserKey = fileName;
            mediaContent.UUID = fileName;

            mediaContent.ContentFile = new ContentFile()
            {
                Name = fileName,
                FileName = fileName,
                Stream = fileStream
            };

            mediaContent.UtcLastModificationDate = mediaContent.UtcCreationDate = DateTime.UtcNow;
            mediaContent.Metadata = metadata;
            Provider.Add(mediaContent, @overrided);

            return mediaContent;
        }
开发者ID:Godoy,项目名称:CMS,代码行数:29,代码来源:MediaContentManager.cs


示例6: SaveMetadata

 public void SaveMetadata(MediaContent mediaContent)
 {
     if (mediaContent.Metadata != null)
     {
         string metadataFile = GetMetadataFilePath(mediaContent);
         Kooboo.Runtime.Serialization.DataContractSerializationHelper.Serialize(mediaContent.Metadata, metadataFile);
     }
 }
开发者ID:Epitomy,项目名称:CMS,代码行数:8,代码来源:MediaContentProvider.cs


示例7: Delete

        public void Delete(MediaContent content)
        {
            var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();

            var contentBlob = blobClient.GetBlobReference(content.GetMediaBlobPath());

            contentBlob.DeleteIfExists();
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:8,代码来源:MediaContentProvider.cs


示例8: DeleteMetadata

 public void DeleteMetadata(MediaContent mediaContent)
 {
     string metadataFile = GetMetadataFilePath(mediaContent);
     if (File.Exists(metadataFile))
     {
         File.Delete(metadataFile);
     }
 }
开发者ID:Epitomy,项目名称:CMS,代码行数:8,代码来源:MediaContentProvider.cs


示例9: MoveMetadata

 public virtual void MoveMetadata(MediaContent old, MediaContent @new)
 {
     var oldPath = GetMetadataFilePath(old);
     if (File.Exists(oldPath))
     {
         var newPath = GetMetadataFilePath(@new);
         File.Move(oldPath, newPath);
     }
 }
开发者ID:RameshGD,项目名称:CMS,代码行数:9,代码来源:MediaContentProvider.cs


示例10: FillMetadata

 public void FillMetadata(MediaContent mediaContent)
 {
     string metadataFile = GetMetadataFilePath(mediaContent);
     if (File.Exists(metadataFile))
     {
         var metadata = Kooboo.Runtime.Serialization.DataContractSerializationHelper.Deserialize<MediaContentMetadata>(metadataFile);
         mediaContent.Metadata = metadata;
         mediaContent["Metadata.Title"] = metadata.Title;
         mediaContent["Metadata.AlternateText"] = metadata.AlternateText;
         mediaContent["Metadata.Description"] = metadata.Description;
     }
 }
开发者ID:Epitomy,项目名称:CMS,代码行数:12,代码来源:MediaContentProvider.cs


示例11: Test_Add_Content

 public void Test_Add_Content()
 {
     MediaContent content = new MediaContent(repository.Name, mediaFolder.FullName);
     content.Published = true;
     content.ContentFile = new ContentFile()
     {
         FileName = "Test_Add_Content.dat",
         Stream = new MemoryStream(new byte[10])
     };
     provider.Add(content);
     Console.WriteLine(content.VirtualPath);
 }
开发者ID:Epitomy,项目名称:CMS,代码行数:12,代码来源:MediaContentProviderTest.cs


示例12: Test_Delete_Content

        public void Test_Delete_Content()
        {
            MediaContent content = new MediaContent(repository.Name, mediaFolder.FullName);
            content.Published = true;
            content.ContentFile = new ContentFile()
            {
                FileName = "Test_Delete_Content.zip",
                Stream = new MemoryStream(new byte[10])
            };
            provider.Add(content);

            provider.Delete(content);
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:13,代码来源:MediaContentProviderTest.cs


示例13: Add

        public void Add(MediaContent content, bool overrided)
        {
            if (content.ContentFile != null)
            {
                content.FileName = content.ContentFile.FileName;

                content.UserKey = content.FileName;
                content.UUID = content.FileName;

                RemoteServiceFactory.CreateService<IMediaContentService>().Add(
                    new MediaContentParameter()
                    {
                        MediaContent = content,
                        FileData = content.ContentFile.Stream.ReadData()
                    });
            }
        }
开发者ID:nikolai80,项目名称:CMS,代码行数:17,代码来源:MediaContentProvider.cs


示例14: BlobToMediaContent

 public static MediaContent BlobToMediaContent(this CloudBlob blob, MediaContent mediaContent)
 {
     if (!string.IsNullOrEmpty(blob.Metadata["Published"]))
     {
         mediaContent.Published = bool.Parse(blob.Metadata["Published"]);
     }
     if (!string.IsNullOrEmpty(blob.Metadata["Size"]))
     {
         mediaContent.Size = int.Parse(blob.Metadata["Size"]);
     }
     mediaContent.FileName = blob.Metadata["FileName"];
     mediaContent.UserKey = mediaContent.FileName;
     mediaContent.UUID = mediaContent.FileName;
     mediaContent.UserId = blob.Metadata["UserId"];
     mediaContent.VirtualPath = blob.Uri.ToString();
     return mediaContent;
 }
开发者ID:rongzhi-Kooboo,项目名称:CMS,代码行数:17,代码来源:MediaBlobHelper.cs


示例15: Test_Get_Content

        public void Test_Get_Content()
        {
            MediaContent content = new MediaContent(repository.Name, mediaFolder.FullName);
            content.Published = true;
            content.UserId = "admin";
            content.ContentFile = new ContentFile()
            {
                FileName = "Test_Get_Content.zip",
                Stream = new MemoryStream(new byte[10])
            };
            provider.Add(content);

            var gotContent = mediaFolder.CreateQuery().WhereEquals("FileName", content.FileName).First();
            Assert.AreEqual(content.FileName, gotContent.FileName);
            Assert.AreEqual(content.UserId, gotContent.UserId);
            Assert.AreEqual(content.Published, gotContent.Published);
            Console.WriteLine(content.VirtualPath, gotContent.VirtualPath);
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:18,代码来源:MediaContentProviderTest.cs


示例16: Add

        public void Add(MediaContent content, bool overrided)
        {
            if (content.ContentFile != null)
            {
                content.FileName = content.ContentFile.FileName;

                content.UserKey = content.FileName;
                content.UUID = content.FileName;

                var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();

                var contentBlob = blobClient.GetBlobReference(content.GetMediaBlobPath());
                contentBlob = content.MediaContentToBlob(contentBlob);

                contentBlob.UploadFromStream(content.ContentFile.Stream);

                content.VirtualPath = contentBlob.Uri.ToString();
            }
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:19,代码来源:MediaContentProvider.cs


示例17: MoveContent

        private static void MoveContent(MediaContent oldMediaContent, MediaContent newMediaContent)
        {
            var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();

            var oldContentBlob = blobClient.GetBlobReference(oldMediaContent.GetMediaBlobPath());
            var newContentBlob = blobClient.GetBlobReference(newMediaContent.GetMediaBlobPath());
            newContentBlob.CopyFromBlob(oldContentBlob);

            oldContentBlob.DeleteIfExists();
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:10,代码来源:MediaContentProvider.cs


示例18: Update

        public void Update(MediaContent @new, MediaContent old)
        {
            if ([email protected](old.FileName, StringComparison.OrdinalIgnoreCase))
            {
                MoveContent(old, @new);
            }
            var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();

            var contentBlob = blobClient.GetBlobReference(@new.GetMediaBlobPath());

            contentBlob = @new.MediaContentToBlob(contentBlob);

            contentBlob.SetMetadata();

            @new.VirtualPath = contentBlob.Uri.ToString();
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:16,代码来源:MediaContentProvider.cs


示例19: Move

        public void Move(MediaFolder sourceFolder, string oldFileName, MediaFolder targetFolder, string newFileName)
        {
            var oldMediaContent = new MediaContent() { Repository = sourceFolder.Repository.Name, FolderName = sourceFolder.FullName, UUID = oldFileName, FileName = oldFileName };
            var newMediaContent = new MediaContent() { Repository = targetFolder.Repository.Name, FolderName = targetFolder.FullName, UUID = newFileName, FileName = newFileName };

            MoveContent(oldMediaContent, newMediaContent);
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:7,代码来源:MediaContentProvider.cs


示例20: SaveContentStream

        public void SaveContentStream(MediaContent content, Stream stream)
        {
            if (stream.Length == 0)
            {
                return;
            }
            var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
            var contentBlob = blobClient.GetBlobReference(content.GetMediaBlobPath());

            if (contentBlob.Exists())
            {
                contentBlob.UploadFromStream(stream);
            }
        }
开发者ID:Godoy,项目名称:CMS,代码行数:14,代码来源:MediaContentProvider.cs



注:本文中的Kooboo.CMS.Content.Models.MediaContent类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Models.MediaFolder类代码示例发布时间:2022-05-26
下一篇:
C# Common.JsonResultData类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap