Esempio n. 1
0
        /// <summary>
        /// Convert this object to a JSON string of itself
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            foreach (var i in Items)
            {
                sb.AppendLine(Resource1.enum_value_template_csharp
                              .Replace("@@COMMENT@@", Fixups.Comment(i.Comment))
                              .Replace("@@VALUE@@", i.Value));
            }

            return(Resource1.enum_class_template_csharp
                   .Replace("@@ENUMCLASS@@", EnumDataType)
                   .Replace("@@COMMENT@@", Fixups.Comment(Comment))
                   .Replace("@@VALUELIST@@", sb.ToString()));
        }
        /// <summary>
        /// Serialize this as a file string
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            foreach (var prop in Properties)
            {
                sb.AppendLine(Resource1.model_property_template_csharp
                              .Replace("@@PROPERTYNAME@@", prop.CSharpParamName)
                              .Replace("@@COMMENT@@", Fixups.Comment(prop.Comment))
                              .Replace("@@PROPERTYTYPE@@", prop.TypeName));
            }

            // Produce the full file
            return(Resource1.model_class_template_csharp
                   .Replace("@@PROPERTYLIST@@", sb.ToString())
                   .Replace("@@COMMENT@@", Fixups.Comment(Comment))
                   .Replace("@@MODELCLASS@@", SchemaName));
        }
Esempio n. 3
0
        public override string ToString()
        {
            // Assemble parameter comments and list
            StringBuilder paramcomments = new StringBuilder();
            StringBuilder paramlist     = new StringBuilder();
            StringBuilder parambuilder  = new StringBuilder();

            foreach (var p in Params)
            {
                paramcomments.AppendFormat("        /// <param name=\"{0}\">{1}</param>\r\n", p.CSharpParamName, p.Comment);
                paramlist.AppendFormat("{0} {1}, ", p.TypeName, p.ParamName.Replace("$", ""));
                parambuilder.AppendFormat("\r\n            path.ApplyField(\"{0}\", {1});", p.ParamName, p.CSharpParamName);
            }
            foreach (var p in QueryParams)
            {
                paramcomments.AppendFormat("        /// <param name=\"{0}\">{1}</param>\r\n", p.CSharpParamName, p.Comment);
                paramlist.AppendFormat("{0} {1}, ", p.TypeName, p.ParamName.Replace("$", ""));
                parambuilder.AppendFormat("\r\n            path.AddQuery(\"{0}\", {1});", p.ParamName, p.CSharpParamName);
            }
            if (BodyParam != null)
            {
                paramcomments.AppendFormat("        /// <param name=\"{0}\">{1}</param>\r\n", BodyParam.CSharpParamName, BodyParam.Comment);
                paramlist.AppendFormat("{0} {1}, ", BodyParam.TypeName, BodyParam.ParamName.Replace("$", ""));
            }
            paramcomments.Append("        /// <returns></returns>");
            if (paramlist.Length > 0)
            {
                paramlist.Length -= 2;
            }

            // Here's your template
            return(Resource1.api_template_csharp
                   .Replace("@@CATEGORY@@", Category)
                   .Replace("@@COMMENT@@", Fixups.Comment(Comment))
                   .Replace("@@TYPENAME@@", TypeName)
                   .Replace("@@APINAME@@", OperationId)
                   .Replace("@@HTTPVERB@@", HttpVerb)
                   .Replace("@@PARAMCOMMENTS@@", paramcomments.ToString())
                   .Replace("@@PARAMBUILDER@@", parambuilder.ToString())
                   .Replace("@@PARAMS@@", paramlist.ToString())
                   .Replace("@@URI@@", URI)
                   .Replace("@@PAYLOAD@@", BodyParam == null ? "null" : "model"));
        }