コード例 #1
0
        /// <summary>
        /// Returns the parameter including validation to submit as FormUrlEncodedContent to my.cyon.ch.
        /// Used in create und update method.
        /// </summary>
        /// <param name="Type"></param>
        /// <param name="Name"></param>
        /// <param name="Value"></param>
        /// <param name="TTL"></param>
        /// <returns></returns>
        private Dictionary <string, string> GetDNSRequestParameters(DNSType Type, string Name, string Value, DNSTTL TTL)
        {
            Dictionary <string, string> content = new Dictionary <string, string>();

            if (Type == DNSType.CNAME)
            {
                string name = Name.EndsWith(this.Name) ? Name.Substring(0, Name.IndexOf(this.Name)) : Name;
                content.Add("zonePrefix", name);
                content.Add("zone", this.Name);
            }
            else
            {
                if (Name.EndsWith("."))
                {
                    content.Add("zone", Name);
                }
                else
                {
                    content.Add("zone", Name + ".");
                }
            }

            content.Add("ttl", ((int)TTL).ToString());
            content.Add("type", Type.ToString().ToUpper());

            if (Type == DNSType.AAAA)
            {
                content.Add("value", WebUtility.UrlEncode(Value));
            }
            else
            {
                content.Add("value", Value);
            }

            return(content);
        }