1+ // Copyright (c) Microsoft Corporation. All rights reserved.
2+ // Licensed under the MIT License.
3+ // <imports>
14using System ;
25using System . IO ;
36using System . Net ;
710using System . Threading . Tasks ;
811using Newtonsoft . Json ;
912using Newtonsoft . Json . Linq ;
13+ // </imports>
1014
11- namespace ConsoleApp7
15+ namespace RecognizeInk
1216{
1317 class Program
1418 {
19+ // <vars>
1520 // Replace the subscriptionKey string with your valid subscription key.
1621 const string subscriptionKey = Environment . GetEnvironmentVariable ( "INK_RECOGNITION_SUBSCRIPTION_KEY" ) ;
1722
1823 // Replace the dataPath string with a path to the JSON formatted ink stroke data.
1924 const string dataPath = @"PATH_TO_INK_STROKE_DATA" ;
2025
21- // URI information for ink recognition:
26+ // URI information for ink recognition. Your endpoint should look like:
27+ // <your-custom-subdomain>.cognitiveservices.azure.com
2228 const string endpoint = Environment . GetEnvironmentVariable ( "INK_RECOGNITION_ENDPOINT" ) ;
2329 const string inkRecognitionUrl = "/inkrecognizer/v1.0-preview/recognize" ;
24-
30+ // </vars>
31+ // <request>
2532 static async Task < string > Request ( string apiAddress , string endpoint , string subscriptionKey , string requestData )
2633 {
2734
@@ -42,9 +49,10 @@ static async Task<string> Request(string apiAddress, string endpoint, string sub
4249 return $ "ErrorCode: { res . StatusCode } ";
4350 }
4451 }
45-
4652 }
53+ // </request>
4754
55+ // <recognize>
4856 static void recognizeInk ( string requestData )
4957 {
5058
@@ -58,10 +66,10 @@ static void recognizeInk(string requestData)
5866 dynamic jsonObj = Newtonsoft . Json . JsonConvert . DeserializeObject ( result ) ;
5967 System . Console . WriteLine ( jsonObj ) ;
6068 }
61-
69+ // </recognize>
70+ // <loadJson>
6271 public static JObject LoadJson ( string fileLocation )
6372 {
64-
6573 var jsonObj = new JObject ( ) ;
6674
6775 using ( StreamReader file = File . OpenText ( fileLocation ) )
@@ -71,7 +79,8 @@ public static JObject LoadJson(string fileLocation)
7179 }
7280 return jsonObj ;
7381 }
74-
82+ // </loadJson>
83+ // <main>
7584 static void Main ( string [ ] args )
7685 {
7786
@@ -81,5 +90,6 @@ static void Main(string[] args)
8190 System . Console . WriteLine ( "\n Press any key to exit " ) ;
8291 System . Console . ReadKey ( ) ;
8392 }
93+ // </main>
8494 }
8595}
0 commit comments