public static DomainReference Parse(string fullName, DomainType domainType) { DomainReference d = null; Match match = null; if (!String.IsNullOrEmpty(fullName)) { switch (domainType) { case DomainType.Set: match = Regex.Match(fullName, String.Format("^{0}$", Utilities.CONSTANTS.SET_REGEX)); if (match.Success) { d = new DomainReference(); d.Type = domainType; d.Name = match.Groups["name"].Value; d.OwnerName = match.Groups["ownerName"].Success ? match.Groups["ownerName"].Value : null; } break; case DomainType.Subverse: match = Regex.Match(fullName, String.Format("^{0}$", Utilities.CONSTANTS.SUBVERSE_REGEX)); if (match.Success) { d = new DomainReference(); d.Type = domainType; d.Name = match.Value; d.OwnerName = null; } break; default: break; } } return(d); }
public static string BasePath(this Domain.Models.DomainReference domainReference, Domain.Models.SortAlgorithm?sort = null) { string path = ""; if (domainReference != null) { switch (domainReference.Type) { case Domain.Models.DomainType.Subverse: path = String.Format("/v/{0}/{1}", domainReference.Name, sort == null ? "" : sort.Value.ToString().ToLower()); break; case Domain.Models.DomainType.Set: path = String.Format("{0}/{1}", Utilities.VoatUrlFormatter.BasePath(domainReference), sort == null ? "" : sort.Value.ToString().ToLower()); break; case Domain.Models.DomainType.User: path = String.Format("/u/{0}", domainReference.Name); break; } } return(path.TrimEnd('/')); }