Exemple #1
0
        public static async Task<bool> IsV2(PackageSource source)
        {
            var url = new Uri(source.Url);

            // If the url is a directory, then it's a V2 source
            if (url.IsFile || url.IsUnc) 
            {
                return !File.Exists(url.LocalPath);
            }

            using (var client = new Data.DataClient())
            {
                var result = await client.GetFile(url);
                if (result == null)
                {
                    return false;
                }

                var raw = result.Value<string>("raw");
                if (raw != null && raw.IndexOf("Packages", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    return true;
                }

                return false;
            }
        }
Exemple #2
0
        public static async Task <bool> IsV2(PackageSource source)
        {
            var url = new Uri(source.Url);

            // If the url is a directory, then it's a V2 source
            if (url.IsFile || url.IsUnc)
            {
                return(!File.Exists(url.LocalPath));
            }

            using (var client = new Data.DataClient())
            {
                var result = await client.GetFile(url);

                if (result == null)
                {
                    return(false);
                }

                var raw = result.Value <string>("raw");
                if (raw != null && raw.IndexOf("Packages", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    return(true);
                }

                return(false);
            }
        }
        private static async Task <bool> IsV2Async(PackageSource source)
        {
            var url = new Uri(source.Url);

            if (url.IsFile || url.IsUnc)
            {
                return(true);
            }

            using (var client = new Data.DataClient())
            {
                var result = await client.GetFile(url);

                if (result == null)
                {
                    return(false);
                }

                var raw = result.Value <string>("raw");
                if (raw != null && raw.IndexOf("Packages", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    return(true);
                }

                return(false);
            }
        }
        private static async Task <bool> IsV3Async(PackageSource source)
        {
            var url = new Uri(source.Url);

            if (url.IsFile || url.IsUnc)
            {
                return(File.Exists(url.LocalPath));
            }

            using (var client = new Data.DataClient())
            {
                var v3index = await client.GetFile(url);

                if (v3index == null)
                {
                    return(false);
                }

                var status = v3index.Value <string>("version");
                if (status != null && status.StartsWith("3.0"))
                {
                    return(true);
                }

                return(false);
            }
        }
        private static async Task<bool> IsV2Async(PackageSource source)
        {
            var url = new Uri(source.Url);
            if (url.IsFile || url.IsUnc)
            {
                return true;
            }

            using (var client = new Data.DataClient())
            {
                var result = await client.GetFile(url);
                if (result == null)
                {
                    return false;
                }

                var raw = result.Value<string>("raw");
                if (raw != null && raw.IndexOf("Packages", StringComparison.OrdinalIgnoreCase) != -1) 
                {
                    return true;
                }

                return false;
            }
        }
        private static async Task<bool> IsV3Async(PackageSource source)
        {
            var url = new Uri(source.Url);
            if (url.IsFile || url.IsUnc)
            {
                return File.Exists(url.LocalPath);
            }

            using (var client = new Data.DataClient())
            {
                var v3index = await client.GetFile(url);
                if (v3index == null)
                {
                    return false;
                }

                var status = v3index.Value<string>("version");
                if (status != null && status.StartsWith("3.0"))
                {
                    return true;
                }

                return false;
            }
        }