コード例 #1
0
        private string GetUri(int articleId, string playerName, AdferoVersion playerVersion, string fallbackPlayerName, AdferoVersion fallbackPlayerVersion, string format, string[] properties, string[] fields)
        {
            Dictionary<string, string> data = new Dictionary<string, string>();

            if (properties != null && properties.Length > 0)
                data["properties"] = string.Join(",", properties);

            if (fields != null && fields.Length > 0)
                data["fields"] = string.Join(",", fields);

            data["articleId"] = articleId.ToString();
            data["playerVersion"] = playerVersion.ToString();

            if (!string.IsNullOrEmpty(fallbackPlayerName))
                data["fallbackPlayerName"] = fallbackPlayerName;

            if (fallbackPlayerVersion != null)
                data["fallbackPlayerVersion"] = fallbackPlayerVersion.ToString();

            List<string> parts = new List<string>();
            foreach (KeyValuePair<string, string> kv in data)
                parts.Add(string.Format("{0}={1}", kv.Key, kv.Value));
            string queryString = HttpUtility.UrlDecode(string.Join("&", parts.ToArray()));

            return string.Format("{0}players/{1}.{2}?{3}", this.baseUri, playerName, format, queryString);
        }