/Serenity.Script.Imports/Services/ServiceCallOptions.cs

https://gitlab.com/pgksunilkumar/Serenity · C# · 197 lines · 52 code · 36 blank · 109 comment · 0 complexity · ace2e809966180c922a90c20a655aec3 MD5 · raw file

  1. using System;
  2. using System.Html;
  3. using System.Runtime.CompilerServices;
  4. using jQueryApi;
  5. using System.Collections.Generic;
  6. namespace Serenity
  7. {
  8. /// <summary>
  9. /// Options for the Q.ServiceCall function
  10. /// </summary>
  11. [Imported, Serializable]
  12. public class ServiceCallOptions<TResponse>
  13. where TResponse: ServiceResponse
  14. {
  15. /// <summary>
  16. /// Gets or sets service URL
  17. /// </summary>
  18. public string Service { get; set; }
  19. /// <summary>
  20. /// Gets or sets a request object to pass to service
  21. /// </summary>
  22. public ServiceRequest Request { get; set; }
  23. /// <summary>
  24. /// Gets or sets a function to call on success with response
  25. /// </summary>
  26. public Action<TResponse> OnSuccess { get; set; }
  27. /// <summary>
  28. /// Gets or sets a function to call on error
  29. /// </summary>
  30. public Action<ServiceResponse> OnError { get; set; }
  31. /// <summary>
  32. /// Gets or sets a function to call to clean resources, after success or error
  33. /// </summary>
  34. public Action OnCleanup { get; set; }
  35. /// <summary>
  36. /// Gets or sets whether to block UI during request (default true)
  37. /// </summary>
  38. public bool BlockUI { get; set; }
  39. /// <summary>
  40. /// Gets or sets whether the request is async.
  41. /// </summary>
  42. public bool Async { get; set; }
  43. /// <summary>
  44. /// Gets or sets the callback to invoke before the request is sent.
  45. /// </summary>
  46. public AjaxSendingCallback BeforeSend { get; set; }
  47. /// <summary>
  48. /// Gets or sets whether the request can be cached.
  49. /// </summary>
  50. public bool Cache { get; set; }
  51. /// <summary>
  52. /// Gets or sets the callback invoked after the request is completed
  53. /// and success or error callbacks have been invoked.
  54. /// </summary>
  55. public AjaxCompletedCallback Complete { get; set; }
  56. /// <summary>
  57. /// Gets or sets the content type of the data sent to the server.
  58. /// </summary>
  59. public string ContentType { get; set; }
  60. /// <summary>
  61. /// Gets or sets the element that will be the context for the request.
  62. /// </summary>
  63. public object Context { get; set; }
  64. /// <summary>
  65. /// A map of dataType-to-dataType converters. Each converter's value is a function that returns the transformed value of the response.
  66. /// </summary>
  67. public JsDictionary<string, Func<string, object>> Converters { get; set; }
  68. /// <summary>
  69. /// Gets or sets the data to be sent to the server.
  70. /// </summary>
  71. public object Data { get; set; }
  72. /// <summary>
  73. /// Gets or sets the data type expected in response from the server.
  74. /// </summary>
  75. public string DataType { get; set; }
  76. /// <summary>
  77. /// Gets or sets the callback to be invoked if the request fails.
  78. /// </summary>
  79. public AjaxErrorCallback Error { get; set; }
  80. /// <summary>
  81. /// Gets or sets the function to be used to handle the raw response data of XMLHttpRequest.
  82. /// </summary>
  83. public AjaxDataFilterCallback DataFilter { get; set; }
  84. /// <summary>
  85. /// Gets or sets whether to trigger global event handlers for this Ajax request.
  86. /// </summary>
  87. public bool Global { get; set; }
  88. /// <summary>
  89. /// Gets or sets whether the request is successful only if its been modified since
  90. /// the last request.
  91. /// </summary>
  92. public bool IfModified { get; set; }
  93. /// <summary>
  94. /// Gets or sets whether the current environment should be treated as a local
  95. /// environment (eg. when the page is loaded using file://).
  96. /// </summary>
  97. public bool IsLocal { get; set; }
  98. /// <summary>
  99. /// Gets or sets the callback parameter name to use for JSONP requests.
  100. /// </summary>
  101. public string Jsonp { get; set; }
  102. /// <summary>
  103. /// Gets or sets the callback name to use for JSONP requests.
  104. /// </summary>
  105. public string JsonpCallback { get; set; }
  106. /// <summary>
  107. /// Gets or sets the mime type of the request.
  108. /// </summary>
  109. public string MimeType { get; set; }
  110. /// <summary>
  111. /// Gets or sets the password to be used for an HTTP authentication request.
  112. /// </summary>
  113. public string Password { get; set; }
  114. /// <summary>
  115. /// Gets or sets whether the data passed in will be processed.
  116. /// </summary>
  117. public bool ProcessData { get; set; }
  118. /// <summary>
  119. /// Gets or sets how to handle character sets for script and JSONP requests.
  120. /// </summary>
  121. public string ScriptCharset { get; set; }
  122. /// <summary>
  123. /// Gets or sets the function to invoke upon successful completion of the request.
  124. /// </summary>
  125. public AjaxRequestCallback Success { get; set; }
  126. /// <summary>
  127. /// Gets or sets the timeout in milliseconds for the request.
  128. /// </summary>
  129. public int Timeout { get; set; }
  130. /// <summary>
  131. /// Gets or sets if you want to use traditional parameter serialization.
  132. /// </summary>
  133. public bool Traditional { get; set; }
  134. /// <summary>
  135. /// Gets or sets the type or HTTP verb associated with the request.
  136. /// </summary>
  137. public string Type { get; set; }
  138. /// <summary>
  139. /// Gets or sets the URL to be requested.
  140. /// </summary>
  141. public string Url { get; set; }
  142. /// <summary>
  143. /// Gets or sets the name of the user to use in a HTTP authentication request.
  144. /// </summary>
  145. public string Username { get; set; }
  146. /// <summary>
  147. /// Gets or sets the function creating the XmlHttpRequest instance.
  148. /// </summary>
  149. [ScriptName("xhr")]
  150. public XmlHttpRequestCreator XmlHttpRequestCreator { get; set; }
  151. /// <summary>
  152. /// Gets or sets a set of additional name/value pairs set of the XmlHttpRequest
  153. /// object.
  154. /// </summary>
  155. public JsDictionary<string, object> XhrFields { get; set; }
  156. }
  157. [Imported, Serializable]
  158. public class ServiceCallOptions : ServiceCallOptions<ServiceResponse>
  159. {
  160. }
  161. }