private void ProcessDestinations() { string[] vDestinations; foreach (KeyValuePair <string, string> vDestination in NuGetDestinations.PushDestinations) { vDestinations = vDestination.Value.Split (Consts.SEMICOLON, StringSplitOptions.RemoveEmptyEntries); if (vDestinations.Length == 0) { continue; } List <NuGetRepository> vRepos = new List <NuGetRepository>(); foreach (string vRepo in vDestinations) { NuGetRepository vFoundRepository = Repositories .FirstOrDefault ( r => r.RepositoryName.Equals (vRepo, StringComparison.OrdinalIgnoreCase) ); if (vFoundRepository == null) { continue; } vRepos.Add(vFoundRepository); } Destinations.Add(vDestination.Key, vRepos); } }
/// <summary> /// Initialize new feed with path resolver and external feeds /// </summary> /// <param name="pathResolver">path resolver for nuget file unpack rules</param> /// <param name="logger">logger for nuget repository</param> /// <param name="feeds">collection of external feeds</param> public NuGetFeed(PathResolver pathResolver, ILogger logger, params string[] feeds) { nuGetRepository = new NuGetRepository(pathResolver, feeds, logger); Expression = Expression.Constant(this); Provider = new NuGetFeedQueryProvider(nuGetRepository); }
private void ProcessRepositories() { string[] vInfo; foreach (KeyValuePair <string, string> vRepository in NuGetRepos.Repositories) { NuGetRepository vNuGetRepository = new NuGetRepository(); vNuGetRepository.RepositoryName = vRepository.Key; vInfo = vRepository.Value.Split (Consts.SEMICOLON, StringSplitOptions.RemoveEmptyEntries); if ((vInfo.Length != 2) && (vInfo.Length != 4) && (vInfo.Length != 1)) { continue; // Just ignore the bad entry } vNuGetRepository.HasSource = (vInfo.Length > 1); vNuGetRepository.HasSymbolSource = vInfo.Length == 4; vNuGetRepository.Source = vInfo[0]; if (vInfo.Length > 1) { vNuGetRepository.SourceApiKey = vInfo[1]; } if (vInfo.Length > 2) { vNuGetRepository.SymbolSource = vInfo[2]; vNuGetRepository.SymbolSourceApiKey = vInfo[3]; } vNuGetRepository.IsNuGetServer = vInfo[0].StartsWith(Consts.HTTP, StringComparison.OrdinalIgnoreCase); Repositories.Add(vNuGetRepository); } }
public NuGetFeed(string localDir, ILogger logger, params string[] feeds) { nuGetRepository = new NuGetRepository(localDir, feeds, logger); Expression = Expression.Constant(this); AsyncProvider = new NuGetFeedQueryProvider(nuGetRepository, Expression); Provider = AsyncProvider; }
private static IAsyncQueryable <NuGetPackage> Materialize(NuGetRepository nuGetRepository, NuGetQueryFilter filter) { var metaRequests = nuGetRepository.Search(filter); var enumer = new AsyncEnumerator <NuGetPackage>(metaRequests); var enumerable = AsyncEnumerable.FromResult(enumer); return(enumerable); }
private static async Task Test1_ApiV3ServiceDisco(NuGetRepository repo) { var desc = await repo.GetRepositoryDescription(); Console.WriteLine("Version: " + desc.Version.ToString()); Console.WriteLine("Mirrors: " + String.Join(", ", desc.Mirrors.Select(u => u.ToString()))); Console.WriteLine("Services:"); foreach (var service in desc.Services) { Console.WriteLine("* " + service.Name + " " + service.RootUrl.ToString()); } }
private static async Task Test2_ApiV2FeedAdaptor(NuGetRepository repo) { // Get the v2 client var packageRepo = await repo.CreateV2FeedClient(); // List the top 10 packages var packages = packageRepo.Search("", Enumerable.Empty <string>(), allowPrereleaseVersions: true).Take(10).ToList(); Console.WriteLine("Top 10 Packages on {0}:", repo.Url); foreach (var package in packages) { Console.WriteLine("* " + package.Id + " " + package.Version.ToString()); } }
internal static IEnumerator <NuGetPackage> Execute(Expression expression, NuGetRepository nuGetRepository) { var nuGetVisitor = GetVisitor(expression); var filter = GetFilter(nuGetVisitor); var deffered = DefferedEnumerator(nuGetRepository, filter); if (!filter.SyncIncompatibility) { return(deffered); } return(Synchronized(deffered, nuGetVisitor.GetNotEvaluated)); }
private static void OutputRepoInfo (NuGetRepository aRepository, int aIndent = 0) { string vIndent = (aIndent > 0) ? "\n" + new String('\t', aIndent) : "\n"; string vHasSource = aRepository.HasSource ? "Yep, it has a source." : "Nope, no source here."; string vIsNuGetServer = aRepository.IsNuGetServer ? "Yep, it's a NuGetServer" : "Nope, it's a share"; string vSource = $"Source: {aRepository.Source}"; string vSourceApiKey = aRepository.IsNuGetServer ? $", Source API Key: {aRepository.SourceApiKey}.{vIndent}" : $", Source is not a NuGet Server, just a share.{vIndent}"; bool vTest = aRepository.HasSymbolSource && !String.IsNullOrWhiteSpace(aRepository.SymbolSource); string vHasSymbolsSource = aRepository.HasSymbolSource ? $"Yep, has a symbol source.{vIndent}" : $"Nope, no symbols source here.{vIndent}"; string vSymbolSource = vTest ? $"Symbol Source: {aRepository.SymbolSource}, " : "No Symbol Source. "; vTest = aRepository.HasSymbolSource && !String.IsNullOrWhiteSpace(aRepository.SymbolSourceApiKey); string vSymbolSourceApiKey = vTest ? $"Symbols Source API Key: {aRepository.SymbolSourceApiKey}." : "No Symbols Source API Key."; Add($"{vIndent}{aRepository.RepositoryName}{vIndent}{vHasSource}{vIndent}{vIsNuGetServer}{vIndent}{vSource}{vSourceApiKey}{vHasSymbolsSource}{vSymbolSource}{vSymbolSourceApiKey}"); Add(); }
private static async Task AsyncMain(string[] args) { string url = "https://api.nuget.org"; if (args.Length > 0) { url = args[0]; } // Setting up the client var repo = new NuGetRepository(new Uri(url), new ColoredConsoleTraceSink()); // 1. Connecting and getting the repository description Console.WriteLine("*** TEST ONE ***"); await Test1_ApiV3ServiceDisco(repo); // 2. Using the V2 Feed through the V3 Client Console.WriteLine("*** TEST TWO ***"); await Test2_ApiV2FeedAdaptor(repo); }
/// <summary> /// Even though all commands in the App.config list will be processed for /// content (basically assign the appropriate values for all replaceable /// tokens in the command line as configured), the only commands placed /// in the list to be spawned will be those that are appropriate to the /// destination (Add for a share, push for an actual NuGet server) and /// appropriate to the desired task e.g. a "delete" command will not be /// issued for a push-type request set and vice-versa. /// </summary> /// <param name="aNuGetRepository"></param> private void PrepareForFullFrameworkProcess (NuGetRepository aNuGetRepository) { _CommandsToExecute.Clear(); _Command = SetupNuGetCommand(); Dictionary <string, string> vCommands = _HandleConfiguration.FullFrameworkCommands.Commands; foreach (KeyValuePair <string, string> vTokenizedParamLine in vCommands) { switch (vTokenizedParamLine.Key.ToLower()) { case NuGetCommands.SPEC: { _CommandLine = NuGetCommands.SPEC.AsSpaceEncapsulated() + BuildNuGetSpec (vTokenizedParamLine.Value); _CommandsToExecute.Add ( NuGetCommands.SPEC , new Tuple <string, string>(_Command.Command, _CommandLine) ); break; } case NuGetCommands.PACK: { _CommandLine = NuGetCommands.PACK.AsSpaceEncapsulated() + BuildNuGetPack ( vTokenizedParamLine.Value , _HandleConfiguration.AppSettingsValues.UseNuSpecFileIfAvailable) ; _CommandsToExecute.Add ( NuGetCommands.PACK , new Tuple <string, string>(_Command.Command, _CommandLine) ); break; } case NuGetCommands.PUSH: { _CommandLine = NuGetCommands.PUSH.AsSpaceEncapsulated() + BuildNuGetPush (vTokenizedParamLine.Value); if (aNuGetRepository.IsNuGetServer) { _CommandsToExecute.Add ( NuGetCommands.PUSH , new Tuple <string, string>(_Command.Command, _CommandLine) ); } break; } case NuGetCommands.ADD: { _CommandLine = NuGetCommands.ADD.AsSpaceEncapsulated() + BuildNuGetAdd (vTokenizedParamLine.Value); if (!aNuGetRepository.IsNuGetServer) { _CommandsToExecute.Add ( NuGetCommands.ADD , new Tuple <string, string>(_Command.Command, _CommandLine) ); } break; } case NuGetCommands.DELETE: { _CommandLine = NuGetCommands.DELETE.AsSpaceEncapsulated() + BuildNuGetDelete (vTokenizedParamLine.Value); if (aNuGetRepository.IsNuGetServer) { _CommandsToExecute.Add ( NuGetCommands.DELETE , new Tuple <string, string>(_Command.Command, _CommandLine) ); } break; } default: { throw new ArgumentOutOfRangeException ($"Unknown switch value: {vTokenizedParamLine.Key}"); } } } }
internal static IAsyncQueryable <NuGetPackage> Execute(Expression expression, NuGetRepository nuGetRepository, Expression root) { var nuGetVisitor = new NuGetExpressionVisitor(); var visitedExpression = nuGetVisitor.Visit(expression); var filter = nuGetVisitor.GetNuGetQueryFilter(); var queryableElements = Materialize(nuGetRepository, filter); if (filter.SyncIncompatibility) { return(Synchronized(queryableElements, nuGetVisitor.GetNotEvaluated)); } return(queryableElements); }
public NuGetFeedQueryProvider(NuGetRepository nuGetRepository) { this.NuGetRepository = nuGetRepository; }
public NuGetFeedQueryProvider(NuGetRepository nuGetRepository, Expression root) { this.NuGetRepository = nuGetRepository; this.root = root; }
private static AsyncEnumerator <NuGetPackage> DefferedEnumerator(NuGetRepository nuGetRepository, NuGetQueryFilter filter) { var metaRequests = nuGetRepository.Search(filter); return(new AsyncEnumerator <NuGetPackage>(metaRequests)); }
private void PrepareForStandardProcess(NuGetRepository aNuGetRepository) { _CommandsToExecute.Clear(); if (!aNuGetRepository.IsNuGetServer) { return; } _Command = SetupNuGetCommand(); Dictionary <string, string> vCommands; switch (Framework) { case DotNetFramework.Standard_2_0: { vCommands = _HandleConfiguration.Standard_2_0_Commands.Commands; break; } default: { throw new UnhandledSwitchCaseException ($"Invalid command set: {Framework}"); } } foreach (KeyValuePair <string, string> vTokenizedParamLine in vCommands) { switch (vTokenizedParamLine.Key.ToLower()) { case DotNetCommands.PACK: { _CommandLine = DotNetCommands.PACK.AsSpaceEncapsulated() + BuildDotNetNuGetPack (vTokenizedParamLine.Value); if (_HandleConfiguration.AppSettingsValues.UseSimulator) { _CommandLine = _Command.Simulator.AsSpaceEncapsulated() + _CommandLine; } _CommandsToExecute.Add ( DotNetCommands.PACK , new Tuple <string, string>(_Command.Command, _CommandLine) ); break; } case DotNetCommands.PUSH: { _CommandLine = _HandleConfiguration.AppSettingsValues.DotNetVerb.AsSpacePrefixed() + DotNetCommands.PUSH.AsSpaceEncapsulated() + BuildDotNetNuGetPush (vTokenizedParamLine.Value); if (_HandleConfiguration.AppSettingsValues.UseSimulator) { _CommandLine = _Command.Simulator.AsSpaceEncapsulated() + _CommandLine; } _CommandsToExecute.Add ( DotNetCommands.PUSH , new Tuple <string, string>(_Command.Command, _CommandLine) ); break; } case DotNetCommands.DELETE: { _CommandLine = _HandleConfiguration.AppSettingsValues.DotNetVerb.AsSpacePrefixed() + DotNetCommands.DELETE.AsSpaceEncapsulated() + BuildDotNetNuGetDelete (vTokenizedParamLine.Value); if (_HandleConfiguration.AppSettingsValues.UseSimulator) { _CommandLine = _Command.Simulator.AsSpaceEncapsulated() + _CommandLine; } if (aNuGetRepository.IsNuGetServer) { _CommandsToExecute.Add ( DotNetCommands.DELETE , new Tuple <string, string>(_Command.Command, _CommandLine) ); } break; } default: { throw new ArgumentOutOfRangeException ($"Unknown switch value: {vTokenizedParamLine.Key}"); } } } }