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


C# Api.Perform方法代码示例

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


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

示例1: Functional

        public Functional()
        {
            var appEnv = CallContextServiceLocator.Locator.ServiceProvider.GetService(typeof(IApplicationEnvironment)) as IApplicationEnvironment;
            Debug.Assert(appEnv != null, "appEnv != null");
            var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath);
            builder.AddJsonFile("config.json");
            builder.AddJsonFile("config.private.json", true);
            var configuration = builder.Build();

            var uri = new Uri(configuration["ServerCredentialUri"]);
            var username = configuration["ServerCredentialUsername"];
            var password = configuration["ServerCredentialPassword"];

            _serverCredential = new ServerCredential(uri, username, password);

            _freeMusicTorrentFile =
                new HttpClient().GetByteArrayAsync(
                    new Uri("http://bt.etree.org/download.php/582271/hottuna2015-09-11.flac16.torrent")).Result;
            _freeMusicTorrentHash = "9ecc7229ff971d27552dd399509e188847dbbbf1";

            // Make sure there is no torrents before executing the tests
            var api = new Api(_serverCredential);
            var torrents = api.GetTorrents().Result;
            if (torrents.Any())
            {
                var result = api.Perform(Action.Removedata, torrents.Select(t => t.InfoHash)).Result;
                Assert.True(result);
            }
        }
开发者ID:rbarbe,项目名称:HadoukenApi,代码行数:29,代码来源:Functional.cs

示例2: ScenarioTypicalUse

        public async Task ScenarioTypicalUse()
        {
            var api = new Api(_serverCredential);

            var resultAddTorrent = await api.AddTorrent(_freeMusicTorrentFile);
            Assert.True(resultAddTorrent);
            Thread.Sleep(60*1000);

            var torrents = await api.GetTorrents();
            Assert.True(torrents.Count == 1);
            Assert.Equal(_freeMusicTorrentHash, torrents.First().InfoHash);

            var properties = await api.GetProperties(_freeMusicTorrentHash);

            properties.Label = "free-music";
            var resultSetProperty = await api.SetProperties(_freeMusicTorrentHash, properties);
            Assert.True(resultSetProperty);
            Thread.Sleep(1500);
            var torrentsAfterLabelChange = await api.GetTorrents();
            Assert.Equal(properties.Label, torrentsAfterLabelChange.First().Label);

            Thread.Sleep(1500);
            var files = await api.GetFiles(_freeMusicTorrentHash);
            var rnd = new Random();
            var randomFileIndex = rnd.Next(files.Count);
            var setFilePriorityResult = await api.SetFilePriority(_freeMusicTorrentHash, randomFileIndex, 0);
            Assert.True(setFilePriorityResult);

            // TODO : Investigate why peers are sometimes unavailable
            //var peers = await api.GetPeers(_freeMusicTorrentHash);
            //Assert.True(peers.Count > 0);

            var deleteResult = await api.Perform(Action.Removedata, _freeMusicTorrentHash);
            Assert.True(deleteResult);
            Thread.Sleep(1500);
            Assert.True((await api.GetTorrents()).Count == 0);
        }
开发者ID:rbarbe,项目名称:HadoukenApi,代码行数:37,代码来源:Functional.cs


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