Exemplo n.º 1
0
        /// <summary>
        /// For the request, build the literals and/or instantiators to assign to each
        /// property in the request shape for which sample data was supplied in the example.
        /// </summary>
        /// <returns>A list of strings of the form 'PropertyName = value' with comments at the
        /// end, if present.</returns>
        public IList <string> GetRequestAssignments(int currentIndent)
        {
            var result = new List <string>();
            var last   = InputParameters.Last().Key;

            foreach (var param in InputParameters)
            {
                var member = Operation.RequestStructure.Members.GetMemberByName(param.Key);

                if (null == member)
                {
                    continue;
                }

                var sb = new StringBuilder();
                var cb = new CodeBuilder(sb, currentIndent);

                cb.Append(member.PropertyName).Append(" = ");
                GetSampleLiteral(member, param.Value, cb);
                if (param.Key != last)
                {
                    cb.Append(",");
                }
                if (InputComments.ContainsKey(param.Key))
                {
                    cb.Append(" // ").Append(InputComments[param.Key]);
                }

                result.Add(sb.ToString());
            }

            return(result);
        }