update code style for apiclient, configuration and apiexception

This commit is contained in:
wing328 2015-07-03 10:36:21 +08:00
parent 422da698f6
commit 57b54d8ad7
10 changed files with 270 additions and 258 deletions

View File

@ -36,47 +36,47 @@ namespace {{packageName}}.Client {
/// <value>The RestClient.</value> /// <value>The RestClient.</value>
public RestClient RestClient { get; set; } public RestClient RestClient { get; set; }
private Dictionary<String, String> defaultHeaderMap = new Dictionary<String, String>(); private Dictionary<String, String> DefaultHeaderMap = new Dictionary<String, String>();
public Object CallApi(String Path, RestSharp.Method Method, Dictionary<String, String> QueryParams, String PostBody, public Object CallApi(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
Dictionary<String, String> HeaderParams, Dictionary<String, String> FormParams, Dictionary<String, FileParameter> FileParams, String[] AuthSettings) { Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, FileParameter> fileParams, String[] authSettings) {
var response = Task.Run(async () => { var response = Task.Run(async () => {
var resp = await CallApiAsync(Path, Method, QueryParams, PostBody, HeaderParams, FormParams, FileParams, AuthSettings); var resp = await CallApiAsync(path, method, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
return resp; return resp;
}); });
return response.Result; return response.Result;
} }
public async Task<Object> CallApiAsync(String Path, RestSharp.Method Method, Dictionary<String, String> QueryParams, String PostBody, public async Task<Object> CallApiAsync(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
Dictionary<String, String> HeaderParams, Dictionary<String, String> FormParams, Dictionary<String, FileParameter> FileParams, String[] AuthSettings) { Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, FileParameter> fileParams, String[] authSettings) {
var request = new RestRequest(Path, Method); var request = new RestRequest(path, method);
UpdateParamsForAuth(QueryParams, HeaderParams, AuthSettings); UpdateParamsForAuth(queryParams, headerParams, authSettings);
// add default header, if any // add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in this.defaultHeaderMap) foreach(KeyValuePair<string, string> defaultHeader in this.DefaultHeaderMap)
request.AddHeader(defaultHeader.Key, defaultHeader.Value); request.AddHeader(defaultHeader.Key, defaultHeader.Value);
// add header parameter, if any // add header parameter, if any
foreach(KeyValuePair<string, string> param in HeaderParams) foreach(KeyValuePair<string, string> param in headerParams)
request.AddHeader(param.Key, param.Value); request.AddHeader(param.Key, param.Value);
// add query parameter, if any // add query parameter, if any
foreach(KeyValuePair<string, string> param in QueryParams) foreach(KeyValuePair<string, string> param in queryParams)
request.AddQueryParameter(param.Key, param.Value); request.AddQueryParameter(param.Key, param.Value);
// add form parameter, if any // add form parameter, if any
foreach(KeyValuePair<string, string> param in FormParams) foreach(KeyValuePair<string, string> param in formParams)
request.AddParameter(param.Key, param.Value); request.AddParameter(param.Key, param.Value);
// add file parameter, if any // add file parameter, if any
foreach(KeyValuePair<string, FileParameter> param in FileParams) foreach(KeyValuePair<string, FileParameter> param in fileParams)
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType); request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
if (PostBody != null) { if (postBody != null) {
request.AddParameter("application/json", PostBody, ParameterType.RequestBody); // http body (model) parameter request.AddParameter("application/json", postBody, ParameterType.RequestBody); // http body (model) parameter
} }
return (Object) await RestClient.ExecuteTaskAsync(request); return (Object) await RestClient.ExecuteTaskAsync(request);
@ -90,7 +90,7 @@ namespace {{packageName}}.Client {
/// <param name="value"> Header field value /// <param name="value"> Header field value
/// <returns></returns> /// <returns></returns>
public void AddDefaultHeader(string key, string value) { public void AddDefaultHeader(string key, string value) {
defaultHeaderMap.Add(key, value); DefaultHeaderMap.Add(key, value);
} }
/// <summary> /// <summary>
@ -98,7 +98,7 @@ namespace {{packageName}}.Client {
/// </summary> /// </summary>
/// <returns>Dictionary of default header</returns> /// <returns>Dictionary of default header</returns>
public Dictionary<String, String> GetDefaultHeader() { public Dictionary<String, String> GetDefaultHeader() {
return defaultHeaderMap; return DefaultHeaderMap;
} }
/// <summary> /// <summary>
@ -224,16 +224,16 @@ namespace {{packageName}}.Client {
/// <param name="QueryParams">Query parameters</param> /// <param name="QueryParams">Query parameters</param>
/// <param name="HeaderParams">Header parameters</param> /// <param name="HeaderParams">Header parameters</param>
/// <param name="AuthSettings">Authentication settings</param> /// <param name="AuthSettings">Authentication settings</param>
public void UpdateParamsForAuth(Dictionary<String, String> QueryParams, Dictionary<String, String> HeaderParams, string[] AuthSettings) { public void UpdateParamsForAuth(Dictionary<String, String> queryParams, Dictionary<String, String> headerParams, string[] authSettings) {
if (AuthSettings == null || AuthSettings.Length == 0) if (authSettings == null || authSettings.Length == 0)
return; return;
foreach (string auth in AuthSettings) { foreach (string auth in authSettings) {
// determine which one to use // determine which one to use
switch(auth) { switch(auth) {
{{#authMethods}} {{#authMethods}}
case "{{name}}": case "{{name}}":
{{#isApiKey}}{{#isKeyInHeader}}HeaderParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInHeader}}{{#isKeyInQuery}}QueryParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}HeaderParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);{{/isBasic}} {{#isApiKey}}{{#isKeyInHeader}}headerParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInHeader}}{{#isKeyInQuery}}queryParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);{{/isBasic}}
{{#isOAuth}}//TODO support oauth{{/isOAuth}} {{#isOAuth}}//TODO support oauth{{/isOAuth}}
break; break;
{{/authMethods}} {{/authMethods}}

View File

@ -5,37 +5,43 @@ namespace {{packageName}}.Client {
/// API Exception /// API Exception
/// </summary> /// </summary>
public class ApiException : Exception { public class ApiException : Exception {
/// <summary> /// <summary>
/// Gets or sets the error code (HTTP status code) /// Gets or sets the error code (HTTP status code)
/// </summary> /// </summary>
/// <value>The error code (HTTP status code).</value> /// <value>The error code (HTTP status code).</value>
public int ErrorCode { get; set; } public int ErrorCode { get; set; }
/// <summary> /// <summary>
/// Gets or sets the error content (body json object) /// Gets or sets the error content (body json object)
/// </summary> /// </summary>
/// <value>The error content (Http response body).</value> /// <value>The error content (Http response body).</value>
public dynamic ErrorContent { get; private set; } public dynamic ErrorContent { get; private set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class. /// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary> /// </summary>
/// <param name="basePath">The base path.</param> /// <param name="basePath">The base path.</param>
public ApiException() {} public ApiException() {}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class. /// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary> /// </summary>
/// <param name="errorCode">HTTP status code.</param> /// <param name="errorCode">HTTP status code.</param>
/// <param name="message">Error message.</param> /// <param name="message">Error message.</param>
public ApiException(int errorCode, string message) : base(message) { public ApiException(int errorCode, string message) : base(message) {
this.ErrorCode = errorCode; this.ErrorCode = errorCode;
} }
public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) { /// <summary>
this.ErrorCode = errorCode; /// Initializes a new instance of the <see cref="ApiException"/> class.
this.ErrorContent = errorContent; /// </summary>
} /// <param name="errorCode">HTTP status code.</param>
/// <param name="message">Error message.</param>
/// <param name="errorContent">Error content.</param>
public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) {
this.ErrorCode = errorCode;
this.ErrorContent = errorContent;
}
} }

View File

@ -7,92 +7,92 @@ using System.Net;
using System.Text; using System.Text;
namespace {{packageName}}.Client { namespace {{packageName}}.Client {
/// <summary>
/// Represents a set of configuration settings
/// </summary>
public class Configuration{
/// <summary> /// <summary>
/// Version of the package /// Represents a set of configuration settings
/// </summary> /// </summary>
public const string Version = "{{packageVersion}}"; public class Configuration{
/// <summary> /// <summary>
/// Gets or sets the default API client for making HTTP calls. /// Version of the package
/// </summary> /// </summary>
/// <value>The API client.</value> public const string Version = "{{packageVersion}}";
public static ApiClient DefaultApiClient = new ApiClient();
/// <summary>
/// <summary> /// Gets or sets the default API client for making HTTP calls.
/// Gets or sets the username (HTTP basic authentication) /// </summary>
/// </summary> /// <value>The API client.</value>
/// <value>The username.</value> public static ApiClient DefaultApiClient = new ApiClient();
public static String Username { get; set; }
/// <summary>
/// <summary> /// Gets or sets the username (HTTP basic authentication)
/// Gets or sets the password (HTTP basic authentication) /// </summary>
/// </summary> /// <value>The username.</value>
/// <value>The password.</value> public static String Username { get; set; }
public static String Password { get; set; }
/// <summary>
/// <summary> /// Gets or sets the password (HTTP basic authentication)
/// Gets or sets the API key based on the authentication name /// </summary>
/// </summary> /// <value>The password.</value>
/// <value>The API key.</value> public static String Password { get; set; }
public static Dictionary<String, String> ApiKey = new Dictionary<String, String>();
/// <summary>
/// <summary> /// Gets or sets the API key based on the authentication name
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name /// </summary>
/// </summary> /// <value>The API key.</value>
/// <value>The prefix of the API key.</value> public static Dictionary<String, String> ApiKey = new Dictionary<String, String>();
public static Dictionary<String, String> ApiKeyPrefix = new Dictionary<String, String>();
/// <summary>
private static string _tempFolderPath = Path.GetTempPath(); /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name
/// </summary>
/// <summary> /// <value>The prefix of the API key.</value>
/// Gets or sets the temporary folder path to store the files downloaded from the server public static Dictionary<String, String> ApiKeyPrefix = new Dictionary<String, String>();
/// </summary>
/// <value>Folder path</value> private static string _tempFolderPath = Path.GetTempPath();
public static String TempFolderPath {
get { /// <summary>
return _tempFolderPath; /// Gets or sets the temporary folder path to store the files downloaded from the server
} /// </summary>
/// <value>Folder path</value>
set { public static String TempFolderPath {
if (String.IsNullOrEmpty(value)) { get {
_tempFolderPath = value; return _tempFolderPath;
return;
} }
// create the directory if it does not exist set {
if (!Directory.Exists(value)) { if (String.IsNullOrEmpty(value)) {
Directory.CreateDirectory(value); _tempFolderPath = value;
} return;
}
// check if the path contains directory separator at the end
if (value[value.Length - 1] == Path.DirectorySeparatorChar) { // create the directory if it does not exist
_tempFolderPath = value; if (!Directory.Exists(value)) {
} else { Directory.CreateDirectory(value);
_tempFolderPath = value + Path.DirectorySeparatorChar; }
// check if the path contains directory separator at the end
if (value[value.Length - 1] == Path.DirectorySeparatorChar) {
_tempFolderPath = value;
} else {
_tempFolderPath = value + Path.DirectorySeparatorChar;
}
} }
} }
/// <summary>
/// Return a string contain essential information for debugging
/// </summary>
/// <value>Folder path</value>
public static String ToDebugReport() {
String report = "C# SDK ({{invokerPackage}}) Debug Report:\n";
report += " OS: " + Environment.OSVersion + "\n";
report += " .NET Framework Version: " + Assembly
.GetExecutingAssembly()
.GetReferencedAssemblies()
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
report += " Swagger Spec Version: {{version}}\n";
report += " SDK Package Version: {{version}}\n";
return report;
}
} }
/// <summary>
/// Return a string contain essential information for debugging
/// </summary>
/// <value>Folder path</value>
public static String ToDebugReport() {
String report = "C# SDK ({{invokerPackage}}) Debug Report:\n";
report += " OS: " + Environment.OSVersion + "\n";
report += " .NET Framework Version: " + Assembly
.GetExecutingAssembly()
.GetReferencedAssemblies()
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
report += " Swagger Spec Version: {{version}}\n";
report += " SDK Package Version: {{version}}\n";
return report;
}
}
} }

View File

@ -36,47 +36,47 @@ namespace IO.Swagger.Client {
/// <value>The RestClient.</value> /// <value>The RestClient.</value>
public RestClient RestClient { get; set; } public RestClient RestClient { get; set; }
private Dictionary<String, String> defaultHeaderMap = new Dictionary<String, String>(); private Dictionary<String, String> DefaultHeaderMap = new Dictionary<String, String>();
public Object CallApi(String Path, RestSharp.Method Method, Dictionary<String, String> QueryParams, String PostBody, public Object CallApi(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
Dictionary<String, String> HeaderParams, Dictionary<String, String> FormParams, Dictionary<String, FileParameter> FileParams, String[] AuthSettings) { Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, FileParameter> fileParams, String[] authSettings) {
var response = Task.Run(async () => { var response = Task.Run(async () => {
var resp = await CallApiAsync(Path, Method, QueryParams, PostBody, HeaderParams, FormParams, FileParams, AuthSettings); var resp = await CallApiAsync(path, method, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
return resp; return resp;
}); });
return response.Result; return response.Result;
} }
public async Task<Object> CallApiAsync(String Path, RestSharp.Method Method, Dictionary<String, String> QueryParams, String PostBody, public async Task<Object> CallApiAsync(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
Dictionary<String, String> HeaderParams, Dictionary<String, String> FormParams, Dictionary<String, FileParameter> FileParams, String[] AuthSettings) { Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, FileParameter> fileParams, String[] authSettings) {
var request = new RestRequest(Path, Method); var request = new RestRequest(path, method);
UpdateParamsForAuth(QueryParams, HeaderParams, AuthSettings); UpdateParamsForAuth(queryParams, headerParams, authSettings);
// add default header, if any // add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in this.defaultHeaderMap) foreach(KeyValuePair<string, string> defaultHeader in this.DefaultHeaderMap)
request.AddHeader(defaultHeader.Key, defaultHeader.Value); request.AddHeader(defaultHeader.Key, defaultHeader.Value);
// add header parameter, if any // add header parameter, if any
foreach(KeyValuePair<string, string> param in HeaderParams) foreach(KeyValuePair<string, string> param in headerParams)
request.AddHeader(param.Key, param.Value); request.AddHeader(param.Key, param.Value);
// add query parameter, if any // add query parameter, if any
foreach(KeyValuePair<string, string> param in QueryParams) foreach(KeyValuePair<string, string> param in queryParams)
request.AddQueryParameter(param.Key, param.Value); request.AddQueryParameter(param.Key, param.Value);
// add form parameter, if any // add form parameter, if any
foreach(KeyValuePair<string, string> param in FormParams) foreach(KeyValuePair<string, string> param in formParams)
request.AddParameter(param.Key, param.Value); request.AddParameter(param.Key, param.Value);
// add file parameter, if any // add file parameter, if any
foreach(KeyValuePair<string, FileParameter> param in FileParams) foreach(KeyValuePair<string, FileParameter> param in fileParams)
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType); request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
if (PostBody != null) { if (postBody != null) {
request.AddParameter("application/json", PostBody, ParameterType.RequestBody); // http body (model) parameter request.AddParameter("application/json", postBody, ParameterType.RequestBody); // http body (model) parameter
} }
return (Object) await RestClient.ExecuteTaskAsync(request); return (Object) await RestClient.ExecuteTaskAsync(request);
@ -90,7 +90,7 @@ namespace IO.Swagger.Client {
/// <param name="value"> Header field value /// <param name="value"> Header field value
/// <returns></returns> /// <returns></returns>
public void AddDefaultHeader(string key, string value) { public void AddDefaultHeader(string key, string value) {
defaultHeaderMap.Add(key, value); DefaultHeaderMap.Add(key, value);
} }
/// <summary> /// <summary>
@ -98,7 +98,7 @@ namespace IO.Swagger.Client {
/// </summary> /// </summary>
/// <returns>Dictionary of default header</returns> /// <returns>Dictionary of default header</returns>
public Dictionary<String, String> GetDefaultHeader() { public Dictionary<String, String> GetDefaultHeader() {
return defaultHeaderMap; return DefaultHeaderMap;
} }
/// <summary> /// <summary>
@ -224,16 +224,16 @@ namespace IO.Swagger.Client {
/// <param name="QueryParams">Query parameters</param> /// <param name="QueryParams">Query parameters</param>
/// <param name="HeaderParams">Header parameters</param> /// <param name="HeaderParams">Header parameters</param>
/// <param name="AuthSettings">Authentication settings</param> /// <param name="AuthSettings">Authentication settings</param>
public void UpdateParamsForAuth(Dictionary<String, String> QueryParams, Dictionary<String, String> HeaderParams, string[] AuthSettings) { public void UpdateParamsForAuth(Dictionary<String, String> queryParams, Dictionary<String, String> headerParams, string[] authSettings) {
if (AuthSettings == null || AuthSettings.Length == 0) if (authSettings == null || authSettings.Length == 0)
return; return;
foreach (string auth in AuthSettings) { foreach (string auth in authSettings) {
// determine which one to use // determine which one to use
switch(auth) { switch(auth) {
case "api_key": case "api_key":
HeaderParams["api_key"] = GetApiKeyWithPrefix("api_key"); headerParams["api_key"] = GetApiKeyWithPrefix("api_key");
break; break;

View File

@ -5,37 +5,43 @@ namespace IO.Swagger.Client {
/// API Exception /// API Exception
/// </summary> /// </summary>
public class ApiException : Exception { public class ApiException : Exception {
/// <summary> /// <summary>
/// Gets or sets the error code (HTTP status code) /// Gets or sets the error code (HTTP status code)
/// </summary> /// </summary>
/// <value>The error code (HTTP status code).</value> /// <value>The error code (HTTP status code).</value>
public int ErrorCode { get; set; } public int ErrorCode { get; set; }
/// <summary> /// <summary>
/// Gets or sets the error content (body json object) /// Gets or sets the error content (body json object)
/// </summary> /// </summary>
/// <value>The error content (Http response body).</value> /// <value>The error content (Http response body).</value>
public dynamic ErrorContent { get; private set; } public dynamic ErrorContent { get; private set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class. /// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary> /// </summary>
/// <param name="basePath">The base path.</param> /// <param name="basePath">The base path.</param>
public ApiException() {} public ApiException() {}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class. /// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary> /// </summary>
/// <param name="errorCode">HTTP status code.</param> /// <param name="errorCode">HTTP status code.</param>
/// <param name="message">Error message.</param> /// <param name="message">Error message.</param>
public ApiException(int errorCode, string message) : base(message) { public ApiException(int errorCode, string message) : base(message) {
this.ErrorCode = errorCode; this.ErrorCode = errorCode;
} }
public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) { /// <summary>
this.ErrorCode = errorCode; /// Initializes a new instance of the <see cref="ApiException"/> class.
this.ErrorContent = errorContent; /// </summary>
} /// <param name="errorCode">HTTP status code.</param>
/// <param name="message">Error message.</param>
/// <param name="errorContent">Error content.</param>
public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) {
this.ErrorCode = errorCode;
this.ErrorContent = errorContent;
}
} }

View File

@ -7,92 +7,92 @@ using System.Net;
using System.Text; using System.Text;
namespace IO.Swagger.Client { namespace IO.Swagger.Client {
/// <summary>
/// Represents a set of configuration settings
/// </summary>
public class Configuration{
/// <summary> /// <summary>
/// Version of the package /// Represents a set of configuration settings
/// </summary> /// </summary>
public const string Version = "1.0.0"; public class Configuration{
/// <summary> /// <summary>
/// Gets or sets the default API client for making HTTP calls. /// Version of the package
/// </summary> /// </summary>
/// <value>The API client.</value> public const string Version = "1.0.0";
public static ApiClient DefaultApiClient = new ApiClient();
/// <summary>
/// <summary> /// Gets or sets the default API client for making HTTP calls.
/// Gets or sets the username (HTTP basic authentication) /// </summary>
/// </summary> /// <value>The API client.</value>
/// <value>The username.</value> public static ApiClient DefaultApiClient = new ApiClient();
public static String Username { get; set; }
/// <summary>
/// <summary> /// Gets or sets the username (HTTP basic authentication)
/// Gets or sets the password (HTTP basic authentication) /// </summary>
/// </summary> /// <value>The username.</value>
/// <value>The password.</value> public static String Username { get; set; }
public static String Password { get; set; }
/// <summary>
/// <summary> /// Gets or sets the password (HTTP basic authentication)
/// Gets or sets the API key based on the authentication name /// </summary>
/// </summary> /// <value>The password.</value>
/// <value>The API key.</value> public static String Password { get; set; }
public static Dictionary<String, String> ApiKey = new Dictionary<String, String>();
/// <summary>
/// <summary> /// Gets or sets the API key based on the authentication name
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name /// </summary>
/// </summary> /// <value>The API key.</value>
/// <value>The prefix of the API key.</value> public static Dictionary<String, String> ApiKey = new Dictionary<String, String>();
public static Dictionary<String, String> ApiKeyPrefix = new Dictionary<String, String>();
/// <summary>
private static string _tempFolderPath = Path.GetTempPath(); /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name
/// </summary>
/// <summary> /// <value>The prefix of the API key.</value>
/// Gets or sets the temporary folder path to store the files downloaded from the server public static Dictionary<String, String> ApiKeyPrefix = new Dictionary<String, String>();
/// </summary>
/// <value>Folder path</value> private static string _tempFolderPath = Path.GetTempPath();
public static String TempFolderPath {
get { /// <summary>
return _tempFolderPath; /// Gets or sets the temporary folder path to store the files downloaded from the server
} /// </summary>
/// <value>Folder path</value>
set { public static String TempFolderPath {
if (String.IsNullOrEmpty(value)) { get {
_tempFolderPath = value; return _tempFolderPath;
return;
} }
// create the directory if it does not exist set {
if (!Directory.Exists(value)) { if (String.IsNullOrEmpty(value)) {
Directory.CreateDirectory(value); _tempFolderPath = value;
} return;
}
// check if the path contains directory separator at the end
if (value[value.Length - 1] == Path.DirectorySeparatorChar) { // create the directory if it does not exist
_tempFolderPath = value; if (!Directory.Exists(value)) {
} else { Directory.CreateDirectory(value);
_tempFolderPath = value + Path.DirectorySeparatorChar; }
// check if the path contains directory separator at the end
if (value[value.Length - 1] == Path.DirectorySeparatorChar) {
_tempFolderPath = value;
} else {
_tempFolderPath = value + Path.DirectorySeparatorChar;
}
} }
} }
/// <summary>
/// Return a string contain essential information for debugging
/// </summary>
/// <value>Folder path</value>
public static String ToDebugReport() {
String report = "C# SDK () Debug Report:\n";
report += " OS: " + Environment.OSVersion + "\n";
report += " .NET Framework Version: " + Assembly
.GetExecutingAssembly()
.GetReferencedAssemblies()
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
report += " Swagger Spec Version: 1.0.0\n";
report += " SDK Package Version: 1.0.0\n";
return report;
}
} }
/// <summary>
/// Return a string contain essential information for debugging
/// </summary>
/// <value>Folder path</value>
public static String ToDebugReport() {
String report = "C# SDK () Debug Report:\n";
report += " OS: " + Environment.OSVersion + "\n";
report += " .NET Framework Version: " + Assembly
.GetExecutingAssembly()
.GetReferencedAssemblies()
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
report += " Swagger Spec Version: 1.0.0\n";
report += " SDK Package Version: 1.0.0\n";
return report;
}
}
} }