当前位置: 首页>>代码示例>>C#>>正文


C# Media.ToList方法代码示例

本文整理汇总了C#中Media.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Media.ToList方法的具体用法?C# Media.ToList怎么用?C# Media.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Media的用法示例。


在下文中一共展示了Media.ToList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateFakeMedias


//.........这里部分代码省略.........
            MediaFolder rootFolder = null;
            if (fakeRoot)
            {
                rootFolder = TestDataProvider.CreateNewMediaFolder(false);
                rootFolder.Folder = null;
                rootFolder.Title = string.Concat("TestFolder_", Guid.NewGuid().ToString());
            }

            var images1 = TestDataProvider.CreateNewMediaFolder(false);
            var images2 = TestDataProvider.CreateNewMediaFolder(false);
            var images1_1 = TestDataProvider.CreateNewMediaFolder(false);
            var images1_2 = TestDataProvider.CreateNewMediaFolder(false);
            var images2_1 = TestDataProvider.CreateNewMediaFolder(false);
            var images1_1_1 = TestDataProvider.CreateNewMediaFolder(false);
            var images1_1_2 = TestDataProvider.CreateNewMediaFolder(false);

            var files1 = TestDataProvider.CreateNewMediaFolder(false, MediaType.File);
            var files1_1 = TestDataProvider.CreateNewMediaFolder(false, MediaType.File);

            images1.Folder = rootFolder;
            images2.Folder = rootFolder;
            images1_1.Folder = images1;
            images1_2.Folder = images1;
            images2_1.Folder = images2;
            images1_1_1.Folder = images1_1;
            images1_1_2.Folder = images1_1;
            files1.Folder = rootFolder;
            files1_1.Folder = files1;

            images1.Title = "Images1";
            images2.Title = "Images2";
            images1_1.Title = "Images1_1";
            images1_2.Title = "Images1_2";
            images2_1.Title = "Images2_1";
            images1_1_1.Title = "Images1_1_1";
            images1_1_2.Title = "Images1_1_2";
            files1.Title = "Files1";
            files1_1.Title = "Files1_1";

            var rootImage1 = TestDataProvider.CreateNewMediaImage();
            var rootImage2 = TestDataProvider.CreateNewMediaImage();
            var rootImage3 = TestDataProvider.CreateNewMediaImage();
            var image1__1 = TestDataProvider.CreateNewMediaImage(images1);
            var image1__2 = TestDataProvider.CreateNewMediaImage(images1);
            var image1_1__1 = TestDataProvider.CreateNewMediaImage(images1_1);
            var rootFile1 = TestDataProvider.CreateNewMediaFile();
            var file1_1 = TestDataProvider.CreateNewMediaFile(files1);

            rootImage1.Folder = rootFolder;
            rootImage2.Folder = rootFolder;
            rootImage3.Folder = rootFolder;
            rootFile1.Folder = rootFolder;

            rootImage1.Title = "RootImage1";
            rootImage2.Title = "RootImage2";
            rootImage3.Title = "RootImage3";
            image1__1.Title = "Image1__1";
            image1__2.Title = "Image1__2";
            image1_1__1.Title = "Image1_1__1";
            rootFile1.Title = "RootFile1";
            file1_1.Title = "File1_1";

            var medias = new Media[] {
                           // Image folders
                           images1,
                           images2,
                           images1_1,
                           images1_2,
                           images2_1,
                           images1_1_1,
                           images1_1_2,

                           // File folders
                           files1,
                           files1_1,

                           // Images
                           rootImage1,
                           rootImage2,
                           rootImage3,
                           image1__1,
                           image1__2,
                           image1_1__1,

                           // Files
                           rootFile1,
                           file1_1
                       };

            if (!fakeRoot)
            {
                var suffix = Guid.NewGuid().ToString();
                medias.ToList().ForEach(m => m.Title = string.Concat(m.Title, "_", suffix));
            }
            medias.ToList().ForEach(m => session.SaveOrUpdate(m));
            session.Flush();
            session.Clear();

            return medias;
        }
开发者ID:eiu165,项目名称:BetterCMS,代码行数:101,代码来源:DefaultMediaApiServiceIntegrationTests.cs


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