@@ -122,12 +122,12 @@ public ClassifyPost Classify(byte[] imageData = null, string imageDataName = nul
122122 ClassifyPost result = null ;
123123
124124 if ( imageData == null && ( urls == null || urls . Length < 1 ) )
125- throw new ArgumentNullException ( string . Format ( "{0} and {1} are required for 'Classify()'" , "' imageData'" , "'urls'" ) ) ;
125+ throw new ArgumentNullException ( string . Format ( "{0} or {1} are required for 'Classify()'" , nameof ( imageData ) , "'urls'" ) ) ;
126126
127127 if ( imageData != null )
128128 {
129129 if ( string . IsNullOrEmpty ( imageDataName ) || string . IsNullOrEmpty ( imageDataMimeType ) )
130- throw new ArgumentException ( string . Format ( "{0} or {1} are required for 'Classify()'" , "' imageDataName'" , "' imageDataMimeType'" ) ) ;
130+ throw new ArgumentException ( string . Format ( "{0} and {1} are required for 'Classify()'" , nameof ( imageDataName ) , nameof ( imageDataMimeType ) ) ) ;
131131 }
132132
133133 if ( owners != null )
@@ -208,12 +208,12 @@ public Faces DetectFaces(byte[] imageData = null, string imageDataName = null, s
208208 Faces result = null ;
209209
210210 if ( imageData == null && ( urls == null || urls . Length < 1 ) )
211- throw new ArgumentNullException ( string . Format ( "{0} and {1} are required for 'DetectFaces()'" , "' imageData'" , "'urls'" ) ) ;
211+ throw new ArgumentNullException ( string . Format ( "{0} or {1} are required for 'DetectFaces()'" , nameof ( imageData ) , "'urls'" ) ) ;
212212
213213 if ( imageData != null )
214214 {
215215 if ( string . IsNullOrEmpty ( imageDataName ) || string . IsNullOrEmpty ( imageDataMimeType ) )
216- throw new ArgumentNullException ( string . Format ( "{0} or {1} are required for 'DetectFaces()'" , "' imageDataName'" , "' imageDataMimeType'" ) ) ;
216+ throw new ArgumentNullException ( string . Format ( "{0} and {1} are required for 'DetectFaces()'" , nameof ( imageDataName ) , nameof ( imageDataMimeType ) ) ) ;
217217 }
218218
219219 try
@@ -310,10 +310,10 @@ public GetClassifiersPerClassifierVerbose CreateClassifier(string classifierName
310310 GetClassifiersPerClassifierVerbose result = null ;
311311
312312 if ( string . IsNullOrEmpty ( classifierName ) )
313- throw new ArgumentNullException ( "'classifierName' is required for 'CreateClassifier()'" ) ;
313+ throw new ArgumentNullException ( nameof ( classifierName ) ) ;
314314
315315 if ( positiveExamplesData == null )
316- throw new ArgumentNullException ( "'positiveExamplesData' is required for 'GetClassifier()'" ) ;
316+ throw new ArgumentNullException ( nameof ( positiveExamplesData ) ) ;
317317
318318 if ( positiveExamplesData . Count < 2 && negativeExamplesData == null )
319319 throw new ArgumentNullException ( "Training a Visual Recognition classifier requires at least two positive example files or one positive example and negative example file." ) ;
@@ -361,7 +361,7 @@ public object DeleteClassifier(string classifierId)
361361 object result = null ;
362362
363363 if ( string . IsNullOrEmpty ( classifierId ) )
364- throw new ArgumentNullException ( "'classifierId' is required for DeleteClassifier()" ) ;
364+ throw new ArgumentNullException ( nameof ( classifierId ) ) ;
365365
366366 try
367367 {
@@ -384,7 +384,7 @@ public object DeleteClassifier(string classifierId)
384384 public GetClassifiersPerClassifierVerbose GetClassifier ( string classifierId )
385385 {
386386 if ( string . IsNullOrEmpty ( classifierId ) )
387- throw new ArgumentNullException ( "'classifierId' is required for 'GetClassifier()'" ) ;
387+ throw new ArgumentNullException ( nameof ( classifierId ) ) ;
388388
389389 GetClassifiersPerClassifierVerbose result = null ;
390390
@@ -409,7 +409,7 @@ public GetClassifiersPerClassifierVerbose UpdateClassifier(string classifierId,
409409 GetClassifiersPerClassifierVerbose result = null ;
410410
411411 if ( string . IsNullOrEmpty ( classifierId ) )
412- throw new ArgumentNullException ( "'classifierId' is required for 'UpdateClassifier()'" ) ;
412+ throw new ArgumentNullException ( nameof ( classifierId ) ) ;
413413
414414 if ( positiveExamplesData == null && negativeExamplesData == null )
415415 throw new ArgumentNullException ( "Positive example data and/or negative example data are required to update a classifier." ) ;
@@ -451,25 +451,5 @@ public GetClassifiersPerClassifierVerbose UpdateClassifier(string classifierId,
451451 return result ;
452452 }
453453 #endregion
454-
455- #region Utils
456- private string GetImageMimeTypeFromFilename ( string filename )
457- {
458- string imageMimeType = "" ;
459- if ( ! string . IsNullOrEmpty ( filename ) )
460- {
461- string ext = Path . GetExtension ( filename ) . ToLower ( ) ;
462-
463- if ( ext == ".jpg" || ext == ".jpeg" )
464- imageMimeType = "image/jpeg" ;
465- else if ( ext == ".png" )
466- imageMimeType = "image/png" ;
467- else
468- throw new ArgumentOutOfRangeException ( nameof ( imageMimeType ) , "Only jpg and png images are accepted." ) ;
469- }
470-
471- return imageMimeType ;
472- }
473- #endregion
474454 }
475455}
0 commit comments