public String BuildUrl(String path) { if (path.StartsWith("http")) { path = WebUtility.UrlEncode(path); } int index = 0; if (ShardStrategy == ShardStrategyType.CRC) { var c = new Crc32(); var hash = c.ComputeCrcHash(path); index = ((int)hash) % Domains.Length; } else if (ShardStrategy == ShardStrategyType.CYCLE) { index = (ShardCycleIndex++) % Domains.Length; } var domain = Domains.ElementAt(index); if (SignWithLibrary) { Parameters.Add("ixlib", String.Format("csharp-{0}", Assembly.GetExecutingAssembly().GetName().Version)); } return(GenerateUrl(path, domain)); }
public String BuildUrl(String path) { if (path.StartsWith("http")) { path = WebUtility.UrlEncode(path); } int index = 0; if (ShardStrategy == ShardStrategyType.CRC) { var c = new Crc32(); var hash = c.ComputeCrcHash(path); index = ((int)hash) % Domains.Length; } else if (ShardStrategy == ShardStrategyType.CYCLE) { index = (ShardCycleIndex++) % Domains.Length; } var domain = Domains.ElementAt(index); if (SignWithLibrary && !Parameters.ContainsKey("ixlib")) { Parameters["ixlib"] = LibraryString; } return(GenerateUrl(path, domain)); }