better style for model, add <value> to all properties

This commit is contained in:
wing328
2015-07-07 16:25:33 +08:00
parent b1b0e28f59
commit e49fe7a12f
20 changed files with 149 additions and 73 deletions

View File

@@ -34,11 +34,13 @@ namespace {{packageName}}.Client
/// <summary>
/// Gets or sets the base path.
/// </summary>
/// <value>The base path</value>
public string BasePath { get; set; }
/// <summary>
/// Gets or sets the RestClient.
/// </summary>
/// <value>An instance of the RestClient</value>
public RestClient RestClient { get; set; }
/// <summary>
@@ -205,28 +207,34 @@ namespace {{packageName}}.Client
{
if (type == typeof(Object)) // return an object
{
return (Object)content;
} else if (type == typeof(Stream))
{
String fileName, filePath;
if (String.IsNullOrEmpty (Configuration.TempFolderPath))
filePath = System.IO.Path.GetTempPath ();
else
filePath = Configuration.TempFolderPath;
Regex regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
Match match = regex.Match(headers.ToString());
if (match.Success) // replace first and last " or ', if found
fileName = filePath + match.Value.Replace("\"", "").Replace("'","");
else
fileName = filePath + Guid.NewGuid().ToString();
return content;
}
File.WriteAllText (fileName, content);
if (type == typeof(Stream))
{
var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
? Path.GetTempPath()
: Configuration.TempFolderPath;
var fileName = filePath + Guid.NewGuid();
if (headers != null)
{
var regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
var match = regex.Match(headers.ToString());
if (match.Success)
fileName = filePath + match.Value.Replace("\"", "").Replace("'", "");
}
File.WriteAllText(fileName, content);
return new FileStream(fileName, FileMode.Open);
} else if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
}
if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
{
return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
} else if (type.Name == "String" || type.Name.StartsWith("System.Nullable")) // return primitive type
}
if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
{
return ConvertType(content, type);
}

View File

@@ -82,10 +82,9 @@ namespace {{packageName}}.Client
/// <summary>
/// Returns a string with essential information for debugging.
/// </summary>
/// <value>Debugging Report</value>
public static String ToDebugReport()
{
String report = "C# SDK ({{invokerPackage}}) Debug Report:\n";
String report = "C# SDK ({{packageName}}) Debug Report:\n";
report += " OS: " + Environment.OSVersion + "\n";
report += " .NET Framework Version: " + Assembly
.GetExecutingAssembly()

View File

@@ -59,6 +59,7 @@ namespace {{packageName}}.Api
/// <summary>
/// Sets the base path of the API client.
/// </summary>
/// <param name="basePath">The base path</param>
/// <value>The base path</value>
public void SetBasePath(String basePath)
{
@@ -68,6 +69,7 @@ namespace {{packageName}}.Api
/// <summary>
/// Gets the base path of the API client.
/// </summary>
/// <param name="basePath">The base path</param>
/// <value>The base path</value>
public String GetBasePath(String basePath)
{
@@ -77,7 +79,7 @@ namespace {{packageName}}.Api
/// <summary>
/// Gets or sets the API client.
/// </summary>
/// <value>The API client.</value>
/// <value>An instance of the ApiClient</param>
public ApiClient ApiClient {get; set;}
{{#operation}}

View File

@@ -15,7 +15,10 @@ namespace {{packageName}}.Model {
[DataContract]
public class {{classname}}{{#parent}} : {{{parent}}}{{/parent}} {
{{#vars}}
{{#description}}/* {{{description}}} */{{/description}}
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
/// </summary>{{#description}}
/// <value>{{{description}}}</value>{{/description}}
[DataMember(Name="{{baseName}}", EmitDefaultValue=false)]
public {{{datatype}}} {{name}} { get; set; }