internal static IRequest ExtendRequest(Dictionary <string, string[]> options, string[] sources, PackageSourceListRequest request) { var srcs = sources ?? new List <string>().ToArray(); var opts = options ?? new Dictionary <string, string[]>(); return((new object[] { new { GetOptionKeys = new Func <IEnumerable <string> >(() => opts.Keys.Any() ? request.OptionKeys.Concat(opts.Keys) : request.OptionKeys), GetOptionValues = new Func <string, IEnumerable <string> >((key) => { if (opts.ContainsKey(key)) { return opts[key]; } return request.GetOptionValues(key); }), GetSources = new Func <IEnumerable <string> >(() => srcs), //ShouldContinueWithUntrustedPackageSource = new Func<string, string, bool>((pkgName, pkgSource) => isTrusted), }, request }).As <IRequest>()); }
internal static IRequest ExtendRequest(Dictionary<string, string[]> options, string[] sources, bool isTrusted, PackageSourceListRequest request) { var srcs = sources ?? new List<string>().ToArray(); var opts = options ?? new Dictionary<string, string[]>(); return (new object[] { new { GetOptionKeys = new Func<IEnumerable<string>>(() => opts.Keys.Any() ? request.OptionKeys.Concat(opts.Keys) : request.OptionKeys), GetOptionValues = new Func<string, IEnumerable<string>>((key) => { if (opts.ContainsKey(key)) { return opts[key]; } return request.GetOptionValues(key); }), GetSources = new Func<IEnumerable<string>>(() => srcs), //ShouldContinueWithUntrustedPackageSource = new Func<string, string, bool>((pkgName, pkgSource) => isTrusted), }, request }).As<IRequest>(); }