/// <summary>
 /// Cheak if all feald set
 /// </summary>
 /// <param name="file"> input file</param>
 /// <returns>
 /// If not set FileConvert.RezultCode == -1
 /// If good FileConvert.RezultCode == 0
 /// </returns>
 private FileConvert CheakFile(FileConvert file)
 {
     if (file == null)
     {
         file            = new FileConvert();
         file.RezultCode = -1;
         file.RezultMsg  = "Empty";
         return(file);
     }
     if (file.File == null && file.File.Length == 0)
     {
         file            = new FileConvert();
         file.RezultCode = -1;
         file.RezultMsg  = "Cant convert empty file";
         return(file);
     }
     if (!CheakFileFormat(file))
     {
         file            = new FileConvert();
         file.RezultCode = -1;
         file.RezultMsg  = "Not support file format";
         return(file);
     }
     file.RezultCode = 0;
     return(file);
 }
 /// <summary>
 /// Convert file
 /// </summary>
 /// <param name="file">Input file with param required: File,FileInForma,FileOutFormat</param>
 /// <returns>
 /// If Error file.RezultCode == -1
 /// If Sucsses file.RezultCode == 0
 /// FileInForma and FileOutFormat change places
 /// </returns>
 public FileConvert ConvertFile(FileConvert file)
 {
     //cheak if all set
     file = CheakFile(file);
     if (file.RezultCode != 0)
     {
         return(file);
     }
     // conver file
     try
     {
         using (MemoryStream ms = new MemoryStream(file.File))
         {
             using (var img = Aspose.Imaging.Image.Load(ms))
             {
                 var file_out_format_option = GetOutPutFormatOption(file.FileOut_extension);
                 //to be honest then this check is unnecessary
                 if (file_out_format_option != null)
                 {
                     img.Save(ms, file_out_format_option);
                 }
                 else
                 {
                     file.RezultCode = -1;
                     file.RezultMsg  = "Error: cant convert";
                     return(file);
                 }
             }
         }
         var in_file_format = file.FileIn_extension;
         file.FileIn_extension  = file.FileOut_extension;
         file.FileOut_extension = in_file_format;
     }
     catch (Exception ex)
     {
         file.RezultCode = -1;
         file.RezultMsg  = "Error: ops :-(";
         return(file);
     }
     return(file);
 }
 /// <summary>
 /// Cheak if can conver file
 /// Rezult: true if can
 /// </summary>
 private bool CheakFileFormat(FileConvert file)
 {
     //cheak if set in and out file format
     if (file.FileIn_extension == string.Empty || file.FileOut_extension == string.Empty)
     {
         return(false);
     }
     //if nead load suport format
     if (suportFormat.Count == 0)
     {
         GetTypesInNamespace();
     }
     //cheak if can convert
     if (suportFormat.ContainsKey(file.FileIn_extension) && suportFormat.ContainsKey(file.FileOut_extension))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }