44using System . Text ;
55using System . Threading . Tasks ;
66using Newtonsoft . Json ;
7+ using Newtonsoft . Json . Linq ;
78using System . Net . Http ;
89
910namespace rosette_api
@@ -59,6 +60,11 @@ public class TranslateNamesResponse : RosetteResponse
5960 /// </summary>
6061 [ JsonProperty ( confidenceKey , NullValueHandling = NullValueHandling . Ignore ) ]
6162 public Nullable < double > Confidence { get ; set ; }
63+ /// <summary>
64+ /// Gets or sets the extended information about the translation
65+ /// </summary>
66+ [ JsonProperty ( extendedInformationKey , NullValueHandling = NullValueHandling . Ignore ) ]
67+ public Dictionary < string , object > ExtendedInformation { get ; set ; }
6268
6369 private const string sourceScriptKey = "sourceScript" ;
6470 private const string sourceLanguageOfOriginKey = "sourceLanguageOfOrigin" ;
@@ -69,6 +75,7 @@ public class TranslateNamesResponse : RosetteResponse
6975 private const string targetSchemeKey = "targetScheme" ;
7076 private const string entityTypeKey = "entityType" ;
7177 private const string confidenceKey = "confidence" ;
78+ private const string extendedInformationKey = "extendedInformation" ;
7279
7380 /// <summary>
7481 /// Creates a TranslateNamesResponse from the given apiResult
@@ -85,6 +92,7 @@ public TranslateNamesResponse(HttpResponseMessage apiResult) :base(apiResult)
8592 this . TargetScheme = this . ContentDictionary . ContainsKey ( targetSchemeKey ) ? this . ContentDictionary [ targetSchemeKey ] as string : null ;
8693 this . EntityType = this . ContentDictionary . ContainsKey ( entityTypeKey ) ? this . ContentDictionary [ entityTypeKey ] as string : null ;
8794 this . Confidence = this . ContentDictionary . ContainsKey ( confidenceKey ) ? this . ContentDictionary [ confidenceKey ] as double ? : null ;
95+ this . ExtendedInformation = this . ContentDictionary . ContainsKey ( extendedInformationKey ) ? ( this . ContentDictionary [ extendedInformationKey ] as JObject ) . ToObject < Dictionary < string , object > > ( ) : null ;
8896 }
8997
9098 /// <summary>
@@ -103,7 +111,8 @@ public TranslateNamesResponse(HttpResponseMessage apiResult) :base(apiResult)
103111 /// <param name="content">The content in Dictionary form</param>
104112 /// <param name="contentAsJson">The content in JSON form</param>
105113 public TranslateNamesResponse ( string translation , string targetLanguage , string targetScheme = null , string targetScript = null , string entityType = null , string sourceLanguageOfOrigin = null ,
106- string sourceLanguageOfUse = null , string sourceScript = null , double ? confidence = null , Dictionary < string , string > responseHeaders = null , Dictionary < string , object > content = null , string contentAsJson = null ) : base ( responseHeaders , content , contentAsJson )
114+ string sourceLanguageOfUse = null , string sourceScript = null , double ? confidence = null , Dictionary < string , object > extendedInformation = null ,
115+ Dictionary < string , string > responseHeaders = null , Dictionary < string , object > content = null , string contentAsJson = null ) : base ( responseHeaders , content , contentAsJson )
107116 {
108117 this . SourceLanguageOfOrigin = sourceLanguageOfOrigin ;
109118 this . SourceLanguageOfUse = sourceLanguageOfUse ;
@@ -114,6 +123,7 @@ public TranslateNamesResponse(string translation, string targetLanguage, string
114123 this . TargetScript = targetScript ;
115124 this . EntityType = entityType ;
116125 this . Confidence = confidence ;
126+ this . ExtendedInformation = extendedInformation ;
117127 }
118128
119129 /// <summary>
@@ -137,7 +147,8 @@ public override bool Equals(object obj)
137147 this . TargetScript != null && other . TargetScript != null ? this . TargetScript . Equals ( other . TargetScript ) : this . TargetScript == other . TargetScript ,
138148 this . EntityType != null && other . EntityType != null ? this . EntityType . Equals ( other . EntityType ) : this . EntityType == other . EntityType ,
139149 this . Confidence == other . Confidence ,
140- this . GetHashCode ( ) == other . GetHashCode ( )
150+ this . GetHashCode ( ) == other . GetHashCode ( ) ,
151+ this . ExtendedInformation != null && other . ExtendedInformation != null ? Utilities . DictionaryEquals ( this . ExtendedInformation , other . ExtendedInformation ) : this . ExtendedInformation == other . ExtendedInformation ,
141152 } ;
142153 return conditions . All ( condition => condition ) ;
143154 }
@@ -163,7 +174,8 @@ public override int GetHashCode()
163174 int h7 = this . TargetScript != null ? this . TargetScript . GetHashCode ( ) : 1 ;
164175 int h8 = this . Translation != null ? this . Translation . GetHashCode ( ) : 1 ;
165176 int h9 = this . Confidence != null ? this . Confidence . GetHashCode ( ) : 1 ;
166- return h0 ^ h1 ^ h2 ^ h3 ^ h4 ^ h5 ^ h6 ^ h7 ^ h8 ^ h9 ;
177+ int h10 = this . ExtendedInformation != null ? this . ExtendedInformation . GetHashCode ( ) : 1 ;
178+ return h0 ^ h1 ^ h2 ^ h3 ^ h4 ^ h5 ^ h6 ^ h7 ^ h8 ^ h9 ^ h10 ;
167179 }
168180 }
169181}
0 commit comments