コード例 #1
0
        public void run()
        {
            while (true)
            {
                String input = inputs.getNextInput();
                if (input == null)
                {
                    break;
                }

                if (File.Exists(input))
                {
                    try
                    {
                        if (config.Multi)
                        {
                            Result[] results = decodeMulti(new Uri(input), config.Hints);
                            if (results != null)
                            {
                                successful++;
                                if (config.DumpResults)
                                {
                                    dumpResultMulti(input, results);
                                }
                            }
                        }
                        else
                        {
                            Result result = decode(new Uri(input), config.Hints);
                            if (result != null)
                            {
                                successful++;
                                if (config.DumpResults)
                                {
                                    dumpResult(input, result);
                                }
                            }
                        }
                    }
                    catch (IOException)
                    {
                    }
                }
                else
                {
                    try
                    {
                        if (decode(new Uri(input), config.Hints) != null)
                        {
                            successful++;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
コード例 #2
0
ファイル: DecodeThread.cs プロジェクト: ryuuji/ZXing.Net
 public void run()
 {
     ResultString = String.Empty;
     while (true)
     {
         String input = inputs.getNextInput();
         if (input == null)
         {
             break;
         }
         try
         {
             Result[] results = decodeMulti(new Uri(Path.GetFullPath(input)), input, config.Hints);
             if (results != null)
             {
                 successful++;
             }
         }
         catch (IOException exc)
         {
             Console.WriteLine(exc.ToString());
         }
     }
 }
コード例 #3
0
ファイル: DecodeThread.cs プロジェクト: n1rvana/ZXing.NET
        public void run()
        {
            ResultString = String.Empty;
            while (true)
            {
                String input = inputs.getNextInput();
                if (input == null)
                {
                    break;
                }

                if (File.Exists(input))
                {
                    try
                    {
                        if (config.Multi)
                        {
                            Result[] results = decodeMulti(new Uri(Path.GetFullPath(input)), input, config.Hints);
                            if (results != null)
                            {
                                successful++;
                                if (config.DumpResults)
                                {
                                    dumpResultMulti(input, results);
                                }
                            }
                        }
                        else
                        {
                            Result result = decode(new Uri(Path.GetFullPath(input)), input, config.Hints);
                            if (result != null)
                            {
                                successful++;
                                if (config.DumpResults)
                                {
                                    dumpResult(input, result);
                                }
                            }
                        }
                    }
                    catch (IOException exc)
                    {
                        Console.WriteLine(exc.ToString());
                    }
                }
                else
                {
                    try
                    {
                        var tempFile = Path.GetTempFileName();
                        var uri      = new Uri(input);
                        var client   = new WebClient();
                        client.DownloadFile(uri, tempFile);
                        try
                        {
                            Result result = decode(new Uri(tempFile), input, config.Hints);
                            if (result != null)
                            {
                                successful++;
                                if (config.DumpResults)
                                {
                                    dumpResult(input, result);
                                }
                            }
                        }
                        finally
                        {
                            File.Delete(tempFile);
                        }
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(exc.ToString());
                    }
                }
            }
        }