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


C# SourceRepository.GetResourceAsync方法代码示例

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


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

示例1: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
        {
            MetadataResourceV3 curResource = null;
            RegistrationResourceV3 regResource = await source.GetResourceAsync<RegistrationResourceV3>(token);

            if (regResource != null)
            {
                var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(token);
                DataClient client = new DataClient(messageHandlerResource.MessageHandler);

                curResource = new MetadataResourceV3(client, regResource);
            }

            return new Tuple<bool, INuGetResource>(curResource != null, curResource);
        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:15,代码来源:MetadataResourceV3Provider.cs

示例2: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
        {
            UISearchResourceV3 curResource = null;
            var serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>(token);

            if (serviceIndex != null)
            {
                var rawSearch = await source.GetResourceAsync<RawSearchResourceV3>(token);
                var metadataResource = await source.GetResourceAsync<UIMetadataResource>(token);

                curResource = new UISearchResourceV3(rawSearch, metadataResource);
            }

            return new Tuple<bool, INuGetResource>(curResource != null, curResource);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:15,代码来源:UISearchResourceV3Provider.cs

示例3: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
        {
            UIMetadataResourceV3 curResource = null;

            if (await source.GetResourceAsync<ServiceIndexResourceV3>(token) != null)
            {
                var regResource = await source.GetResourceAsync<RegistrationResourceV3>();
                var reportAbuseResource = await source.GetResourceAsync<ReportAbuseResourceV3>();

                // construct a new resource
                curResource = new UIMetadataResourceV3(_client, regResource, reportAbuseResource);
            }

            return new Tuple<bool, INuGetResource>(curResource != null, curResource);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:15,代码来源:UIMetadataResourceV3Provider.cs

示例4: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
        {
            PSAutoCompleteResourceV3 curResource = null;

            var serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>(token);

            if (serviceIndex != null)
            {
                var regResource = await source.GetResourceAsync<RegistrationResourceV3>(token);

                // construct a new resource
                curResource = new PSAutoCompleteResourceV3(_client, serviceIndex, regResource);
            }

            return new Tuple<bool, INuGetResource>(curResource != null, curResource);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:16,代码来源:PSAutoCompleteResourceV3Provider.cs

示例5: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken cancellationToken)
        {
            V3TotalsStatsResource totalsStatsResource = null;
            var serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>(cancellationToken);

            if (serviceIndex != null)
            {
                // TODO: fix this for resource templates
                throw new NotImplementedException();

                //ResourceSelector resourceSelector = new ResourceSelector(source);

                //IList<Uri> resourceUrls = serviceIndex[ServiceTypes.TotalStats];
                //Uri resourceUri = await resourceSelector.DetermineResourceUrlAsync(resourceUrls, cancellationToken);

                //var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(cancellationToken);
                //DataClient client = new DataClient(messageHandlerResource.MessageHandler);


                //// construct a new resource
                //totalsStatsResource = new V3TotalsStatsResource(client, resourceUri);
            }

            return new Tuple<bool, INuGetResource>(totalsStatsResource != null, totalsStatsResource);
        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:25,代码来源:V3TotalsStatsResourceProvider.cs

示例6: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
        {
            SearchLatestResourceV3 curResource = null;
            ServiceIndexResourceV3 serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>(token);

            if (serviceIndex != null)
            {
                var rawSearch = await source.GetResourceAsync<RawSearchResourceV3>(token);

                if (rawSearch != null)
                {
                    curResource = new SearchLatestResourceV3(rawSearch);
                }
            }

            return new Tuple<bool, INuGetResource>(curResource != null, curResource);
        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:17,代码来源:SearchLatestResourceV3Provider.cs

示例7: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
        {
            DependencyInfoResource curResource = null;

            if (await source.GetResourceAsync<ServiceIndexResourceV3>(token) != null)
            {
                var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(token);

                var client = new DataClient(messageHandlerResource.MessageHandler);

                var regResource = await source.GetResourceAsync<RegistrationResourceV3>(token);

                // construct a new resource
                curResource = new DependencyInfoResourceV3(client, regResource, source);
            }

            return new Tuple<bool, INuGetResource>(curResource != null, curResource);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:18,代码来源:DependencyInfoResourceV3Provider.cs

示例8: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
        {
            RegistrationResourceV3 regResource = null;
            var serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>(token);

            if (serviceIndex != null)
            {
                Uri baseUrl = serviceIndex[ServiceTypes.RegistrationsBaseUrl].FirstOrDefault();

                var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(token);

                DataClient client = new DataClient(messageHandlerResource.MessageHandler);

                // construct a new resource
                regResource = new RegistrationResourceV3(client, baseUrl);
            }

            return new Tuple<bool, INuGetResource>(regResource != null, regResource);
        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:19,代码来源:RegistrationResourceV3Provider.cs

示例9: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
        {
            RawSearchResourceV3 curResource = null;
            ServiceIndexResourceV3 serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>();

            if (serviceIndex != null)
            {
                var endpoints = serviceIndex[ServiceTypes.SearchQueryService].ToArray();

                if (endpoints.Length > 0)
                {
                    var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(token);

                    // construct a new resource
                    curResource = new RawSearchResourceV3(messageHandlerResource.MessageHandler, endpoints);
                }
            }

            return new Tuple<bool, INuGetResource>(curResource != null, curResource);
        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:20,代码来源:RawSearchResourceV3Provider.cs

示例10: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
        {
            PSSearchResource resource = null;
            UISearchResource uiSearchResource = await source.GetResourceAsync<UISearchResource>(token);
            if (uiSearchResource != null)
            {
                resource = new PowerShellSearchResourceV2(uiSearchResource);
            }

            return new Tuple<bool, INuGetResource>(resource != null, resource);
        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:11,代码来源:PSSearchResourceV2Provider.cs

示例11: GetRepository

        protected async Task<V2Resource> GetRepository(SourceRepository source, CancellationToken token)
        {
            var repositoryResource = await source.GetResourceAsync<PackageRepositoryResourceV2>(token);

            if (repositoryResource != null && repositoryResource.V2Client != null)
            {
                return repositoryResource;
            }

            return null;
        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:11,代码来源:V2ResourceProvider.cs

示例12: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
        {
            ApiAppSearchResource resource = null;

            var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(token);
            ServiceIndexResourceV3 serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>();

            if (messageHandlerResource != null && serviceIndex != null)
            {
                var endpoints = serviceIndex["ApiAppSearchQueryService"];

                if (endpoints.Any())
                {
                    RawSearchResourceV3 rawSearch = new RawSearchResourceV3(messageHandlerResource.MessageHandler, endpoints);

                    resource = new ApiAppSearchResource(rawSearch);
                }
            }

            return new Tuple<bool, INuGetResource>(resource != null, resource);
        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:21,代码来源:ApiAppSearchResourceProvider.cs

示例13: GetDownloadStream

        private static async Task<Stream> GetDownloadStream(SourceRepository sourceRepository, PackageIdentity packageIdentity, CancellationToken token)
        {
            Stream downloadStream = null;
            DownloadResource downloadResource = await sourceRepository.GetResourceAsync<DownloadResource>(token);
            if(downloadResource != null)
            {
                downloadStream = await downloadResource.GetStream(packageIdentity, token);
                return downloadStream;
            }

            return null;
        }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:12,代码来源:PackageDownloader.cs

示例14: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
        {
            SimpleSearchResourceV3 curResource = null;

            var rawSearch = await source.GetResourceAsync<RawSearchResourceV3>(token);

            if (rawSearch != null && rawSearch is RawSearchResourceV3)
            {
                curResource = new SimpleSearchResourceV3(rawSearch);
            }

            return new Tuple<bool, INuGetResource>(curResource != null, curResource);
        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:13,代码来源:SimpleSearchResourceV3Provider.cs

示例15: TryCreate

        public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository sourceRepository, CancellationToken token)
        {
            INuGetResource resource = null;

            var serviceIndexResource = await sourceRepository.GetResourceAsync<ServiceIndexResourceV3>();

            if (serviceIndexResource != null)
            {
                resource = new RemoteV3FindPackageByIdResource(sourceRepository);
            }

            return Tuple.Create(resource != null, resource);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:13,代码来源:RemoteV3FindPackagePackageByIdResourceProvider.cs


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