private static Projects GetProjectsByUsername(string host, string username) { Assert.ValidInput(username, "username"); Assert.ValidInput(host, "host"); ProjectHost projectHost = ProjectHostExtensions.GetProjectHost(host); Assert.ValidInput(projectHost.ToString(), "host"); var projects = new List <Project>().GetFromCache(projectHost, username); if (projects != null) { return(new Projects(projects)); } switch (projectHost) { case ProjectHost.GoogleCode: projects = GoogleCodeProjectsByUsername(username); break; case ProjectHost.GitHub: projects = GitHubProjectsByUsername(username); break; } return(new Projects(projects.AddToCache(projectHost, username))); }
public Projects GetProjectsByProjectHostAndUsername(string projectHostUsernamePair, string filters) { var hostAndUsername = ProjectHostExtensions.ParseProjectHostAndUsername(projectHostUsernamePair); var projects = new List <Project>(); foreach (var hostUsername in hostAndUsername) { projects.AddRange(GetProjectsByUsername(hostUsername.Key, hostUsername.Value)); } return(new Projects(projects.Filter(filters).OrderBy(p => p.Name).ThenByDescending(p => string.IsNullOrEmpty(p.LastModified) ? DateTime.Now : DateTime.Parse(p.LastModified)))); }