Ejemplo n.º 1
0
        static bool TestDateParserError(string failString)
        {
            DateTime dtParsed;

            if (ExifTool.TryParseDate(failString, DateTimeKind.Unspecified, out dtParsed))
            {
                Console.WriteLine("Date parse should have failed: {0}", failString);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        static bool TestDateParser(int year, int month, int day, int hour, int minute, int second)
        {
            string   dtFormatted = string.Format("{0:D4}:{1:D2}:{2:D2} {3:D2}:{4:D2}:{5:D2}", year, month, day, hour, minute, second);
            DateTime dtParsed;

            if (!ExifTool.TryParseDate(dtFormatted, DateTimeKind.Unspecified, out dtParsed))
            {
                Console.WriteLine("Date Parse failed to parse: {0}", dtFormatted);
                return(false);
            }

            DateTime dtComposed = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Unspecified);

            if (!dtParsed.Equals(dtComposed))
            {
                Console.WriteLine("Date Parse doesn't match: {0}", dtFormatted);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                if (args.Length == 0)
                {
                    args = new string[] { "-h" };
                }

                s_exifTool = new ExifTool();

                foreach (var arg in args)
                {
                    if (arg.Equals("-h", StringComparison.OrdinalIgnoreCase) ||
                        arg.Equals("-?", StringComparison.OrdinalIgnoreCase))
                    {
                        Console.WriteLine(c_helpText);
                    }

                    ProcessFiles(arg);
                }

                TestDateParser();
            }
            catch (Exception err)
            {
                Console.WriteLine(err.ToString());
            }
            finally
            {
                if (s_exifTool != null)
                {
                    // this is the paranoid way to dispose. It handles the case were ExifTool.Dispose() throws an exception.
                    var temp = s_exifTool;
                    s_exifTool = null;
                    temp.Dispose();
                }
            }

            Win32Interop.ConsoleHelper.PromptAndWaitIfSoleConsole();
        }