Ejemplo n.º 1
0
        public static bool CheckPackageSource(ISettings settings, string name)
        {
            var packageSources = settings.GetSection("packageSources");

            if (packageSources != null)
            {
                foreach (var packageSource in packageSources.Items.OfType <SourceItem>().ToList())
                {
                    if (packageSource.Key == name)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        private static void RemoveSources(ISettings settings, string prefixName)
        {
            var packageSources = settings.GetSection("packageSources");

            if (packageSources != null)
            {
                foreach (var packageSource in packageSources.Items.OfType <SourceItem>().ToList())
                {
                    var path = packageSource.GetValueAsPath();

                    if (packageSource.Key.StartsWith(prefixName))
                    {
                        // Remove entry from packageSources
                        settings.Remove("packageSources", packageSource);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static void RemoveDeletedSources(ISettings settings, string prefixName)
        {
            var packageSources = settings.GetSection("packageSources");

            if (packageSources != null)
            {
                foreach (var packageSource in packageSources.Items.OfType <SourceItem>().ToList())
                {
                    var path = packageSource.GetValueAsPath();

                    if (packageSource.Key.StartsWith(prefixName) &&
                        Uri.TryCreate(path, UriKind.Absolute, out var uri) && uri.IsFile && // make sure it's a valid file URI
                        !Directory.Exists(path))    // detect if directory has been deleted
                    {
                        // Remove entry from packageSources
                        settings.Remove("packageSources", packageSource);
                    }
                }
            }
        }