| | | 1 | | // <auto-generated> |
| | | 2 | | // Code generated by Microsoft (R) AutoRest Code Generator. |
| | | 3 | | // Changes may cause incorrect behavior and will be lost if the code is |
| | | 4 | | // regenerated. |
| | | 5 | | // </auto-generated> |
| | | 6 | | |
| | | 7 | | namespace Microsoft.Azure.CognitiveServices.Search.WebSearch.Models |
| | | 8 | | { |
| | | 9 | | using Microsoft.Rest; |
| | | 10 | | using Newtonsoft.Json; |
| | | 11 | | using System.Collections; |
| | | 12 | | using System.Collections.Generic; |
| | | 13 | | using System.Linq; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Defines an expression and its answer |
| | | 17 | | /// </summary> |
| | | 18 | | public partial class Computation : Answer |
| | | 19 | | { |
| | | 20 | | /// <summary> |
| | | 21 | | /// Initializes a new instance of the Computation class. |
| | | 22 | | /// </summary> |
| | 0 | 23 | | public Computation() |
| | | 24 | | { |
| | | 25 | | CustomInit(); |
| | 0 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Initializes a new instance of the Computation class. |
| | | 30 | | /// </summary> |
| | | 31 | | /// <param name="expression">The math or conversion expression. If the |
| | | 32 | | /// query contains a request to convert units of measure (for example, |
| | | 33 | | /// meters to feet), this field contains the from units and value |
| | | 34 | | /// contains the to units. If the query contains a mathematical |
| | | 35 | | /// expression such as 2+2, this field contains the expression and |
| | | 36 | | /// value contains the answer. Note that mathematical expressions may |
| | | 37 | | /// be normalized. For example, if the query was sqrt(4^2+8^2), the |
| | | 38 | | /// normalized expression may be sqrt((4^2)+(8^2)). If the user's query |
| | | 39 | | /// is a math question and the textDecorations query parameter is set |
| | | 40 | | /// to true, the expression string may include formatting markers. For |
| | | 41 | | /// example, if the user's query is log(2), the normalized expression |
| | | 42 | | /// includes the subscript markers. For more information, see Hit |
| | | 43 | | /// Highlighting.</param> |
| | | 44 | | /// <param name="value">The expression's answer.</param> |
| | | 45 | | /// <param name="id">A String identifier.</param> |
| | | 46 | | /// <param name="webSearchUrl">The URL To Bing's search result for this |
| | | 47 | | /// item.</param> |
| | | 48 | | public Computation(string expression, string value, string id = default(string), string webSearchUrl = default(s |
| | 0 | 49 | | : base(id, webSearchUrl, followUpQueries) |
| | | 50 | | { |
| | 0 | 51 | | Expression = expression; |
| | 0 | 52 | | Value = value; |
| | | 53 | | CustomInit(); |
| | 0 | 54 | | } |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// An initialization method that performs custom operations like setting defaults |
| | | 58 | | /// </summary> |
| | | 59 | | partial void CustomInit(); |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Gets or sets the math or conversion expression. If the query |
| | | 63 | | /// contains a request to convert units of measure (for example, meters |
| | | 64 | | /// to feet), this field contains the from units and value contains the |
| | | 65 | | /// to units. If the query contains a mathematical expression such as |
| | | 66 | | /// 2+2, this field contains the expression and value contains the |
| | | 67 | | /// answer. Note that mathematical expressions may be normalized. For |
| | | 68 | | /// example, if the query was sqrt(4^2+8^2), the normalized expression |
| | | 69 | | /// may be sqrt((4^2)+(8^2)). If the user's query is a math question |
| | | 70 | | /// and the textDecorations query parameter is set to true, the |
| | | 71 | | /// expression string may include formatting markers. For example, if |
| | | 72 | | /// the user's query is log(2), the normalized expression includes the |
| | | 73 | | /// subscript markers. For more information, see Hit Highlighting. |
| | | 74 | | /// </summary> |
| | | 75 | | [JsonProperty(PropertyName = "expression")] |
| | 0 | 76 | | public string Expression { get; set; } |
| | | 77 | | |
| | | 78 | | /// <summary> |
| | | 79 | | /// Gets or sets the expression's answer. |
| | | 80 | | /// </summary> |
| | | 81 | | [JsonProperty(PropertyName = "value")] |
| | 0 | 82 | | public string Value { get; set; } |
| | | 83 | | |
| | | 84 | | /// <summary> |
| | | 85 | | /// Validate the object. |
| | | 86 | | /// </summary> |
| | | 87 | | /// <exception cref="ValidationException"> |
| | | 88 | | /// Thrown if validation fails |
| | | 89 | | /// </exception> |
| | | 90 | | public virtual void Validate() |
| | | 91 | | { |
| | 0 | 92 | | if (Expression == null) |
| | | 93 | | { |
| | 0 | 94 | | throw new ValidationException(ValidationRules.CannotBeNull, "Expression"); |
| | | 95 | | } |
| | 0 | 96 | | if (Value == null) |
| | | 97 | | { |
| | 0 | 98 | | throw new ValidationException(ValidationRules.CannotBeNull, "Value"); |
| | | 99 | | } |
| | 0 | 100 | | } |
| | | 101 | | } |
| | | 102 | | } |