Exemplo n.º 1
0
        /// <summary>
        /// Return formatted value string for the parameter.
        /// </summary>
        /// <returns></returns>
        public string ValueForMap()
        {
            if (IsAPIVersion)
            {
                return(APIVersionName);
            }

            var value = IsClientProperty
                ? "client." + CodeNamerGo.Instance.GetPropertyName(Name.Value)
                : Name.Value;

            var format = IsRequired || ModelType.CanBeEmpty()
                                          ? "{0}"
                                          : "*{0}";

            var s = CollectionFormat != CollectionFormat.None
                                  ? $"{format},\"{CollectionFormat.GetSeparator()}\""
                                  : $"{format}";

            return(string.Format(
                       RequiresUrlEncoding()
                    ? $"autorest.Encode(\"{Location.ToString().ToLower()}\",{s})"
                    : $"{s}",
                       value));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Return formatted value string for the parameter.
        /// </summary>
        /// <returns></returns>
        public string ValueForMap(bool useDefault = false)
        {
            if (IsAPIVersion)
            {
                return(APIVersionName);
            }

            if (IsConstant)
            {
                return(RequiresUrlEncoding() ?
                       $"autorest.Encode(\"{Location.ToString().ToLower()}\", {DefaultValueString})" :
                       DefaultValueString);
            }

            string value = "";

            if (useDefault)
            {
                value = DefaultValueString;
            }
            else if (IsClientProperty)
            {
                value = GetClientPropertryName();
            }
            else
            {
                value = Name.Value;
            }

            var format = IsRequired || ModelType.CanBeEmpty() || useDefault
                                          ? "{0}"
                                          : "*{0}";

            var s = CollectionFormat != CollectionFormat.None
                                  ? $"{format},\"{CollectionFormat.GetSeparator()}\""
                                  : $"{format}";

            return(string.Format(
                       RequiresUrlEncoding()
                    ? $"autorest.Encode(\"{Location.ToString().ToLower()}\",{s})"
                    : $"{s}",
                       value));
        }